Search |
||
When does JavaSE becomes a better choice than JavaME CDC?Posted by mlam on November 23, 2006 at 2:17 PM PST
A comment from my last entry on performance, asked, "I was thinking about the fact that devices [increasingly] get more power and more RAM. I thought when will JavaSE be a better choice instead of JavaME/CDC1.1? How much CPU, RAM, cache....do you need?" Before I answer this, I must first make the disclaimer that my opinions are my own as an engineer, and not necessarily that of my employer, Sun, or even other engineers at Sun. With that said, now let's get into the question ... JavaSE or JavaME? Device Capability Device capability isn't only about the choice of processors. Take PowerPC for example. It has embedded variants as well as the more well known desktop and server versions. The processor core is mostly the same (i.e. will execute the same code), but other capabilities are different. The most obvious would be differences in clock speed, and cache. And then, there are other hardware differences (e.g. board level) in capability: cache architecture, L2 cache, main RAM capacity, RAM speed, bus speed, memory and I/O bus architecture, I/O processors, MMU, DMA, TLAB size, secondary storage (HardDisks, FlashDisks), etc. ... or, the lack thereof. The more of these features your device has, the more likely JavaSE is a better fit, and vice versa. Just looking at memory capacity alone, I think JavaSE typically operates with a footprint in the order of 10s to 100s of MBs, or even GBs. CVM operates in the order of 1s to the low 10s of MBs. Of course, a lot of this depends on what your application is doing (for both JavaSE and CVM). But those numbers should give you an idea. So, if your device only has 16MB RAM, CVM will probably be your best bet. If you have 32MB of RAM, it gets a little gray, and depends on what you are trying to achieve. CVM is still usually your best bet for most embedded applications. Low 100MBs, it is still gray but tending more towards JavaSE now. If the device has 1 GB or more, I would be fairly confident that JavaSE is better suited here. As for cache, it's a lot harder to tell. 0 to 10s KBs, go with CVM. 10s to 100s of KBs, it's a gray area. MBs of cache, you can definitely run JavaSE now, but this doesn't mean that CVM isn't still the better choice in some cases. For clock speeds, 10s to low 100s of MHz, CVM is your better choice. Low 100 MHzs to 1GHz, it's gray. More than 1GHz, JavaSE is the likely choice. But as Sun has shown not too long ago, CPU performance isn't all about clock speeds (see CoolThreads). So, take the above numbers with a grain of salt. In fact, all the ranges I've given above are just educated guesses based on my experience in this field. They can be used as a hints, but a real world case can be different. That's why there's no hard fast rule as to which fits better in any given case. Now that we're talked about the obvious stuff, let's get into all the "gotchas" that people may not think about ...the Mind of an Embedded Systems Developer So, what does this mean to the embedded software (and JavaME) developer? Portability Sometimes, a manufacturer will also want to offer different grades of hardware with different capabilities e.g. low-end and high-end devices for 2 different market segments. These devices may not always be built on the same CPU architecture. This is why JavaME is compelling (write once run anywhere). But WORA depends on the presence of a Java VM port. So, the portability of the VM is important. After all, there is development cost involved with the porting effort, and it makes sense that the manufacturer will want to minimize this. This is one area where CVM fits better. As I've explained in a prior article, CVM was architected to be easily ported to different platforms. This is not to say that JavaSE can't be ported, but it will not be as easy to do so. I have also pointed out previously that portability comes with a cost in performance. Though this cost is usually negligible in most cases, it is there. This is why CVM's performance in general will not match JavaSE on more capable devices, and conversely, why JavaSE will be harder to port. CVM chose portability. JavaSE chose performance. Ubiquity The fact that embedded systems are highly varied is why CVM is architected for portability. It is a necessary tradeoff. Compliance with Specifications Fit for Purpose Case 1: Your device is an x86 box that you're only manufacturing in limited quantity (say in the 10s or low 100s), and you can charge a lot of money for it. It comes with 1G of memory, and a hard disk storage. It primarily needs to run only one Java application. The application may be heavily threaded. Performance is critical. The application is special purposed and is sold only with the box. The box is not expected to run other applications, though you may send it upgrades to your application. Chances are you will want JavaSE. The key: desktop/server class hardware, critical performance, special purposed software i.e. not subject to open standards compliance. Case 2: Your device will be sold to millions. It runs an ARM processor. 32M RAM. Only on-chip cache. It is used in a vertical market with their own specification which has components based on JavaME CDC 1.1. Chances are you will want CVM. The key: device needs to be cheap, minimal/low capability, needs CDC compliance. Case 3: Your device is a server that needs to run JavaEE servlets ... about 1000 of them at the same time at any given moment. Each servlet needs to run in its own process, not thread. The servlet itself may be multi-threaded. The servlets are expected to be short lived, but there's just a lot of them. Performance is critical. Each servlet handles a service call coming in from the net. The services are headless (i.e. no graphics), and are not compute bound (i.e. no huge number crunching problems to solve). If the servlets are unresponsive enough, users of the device will be annoyed ... extremely annoyed. The device has 4GB of memory, and is configured with 4 super duper fast CPUs. Needs JavaEE compliance. The obvious answer is ... JavaSE? Not necessarily. Here's why: JavaSE has a larger footprint than CVM. Let's say the base foot print of JavaSE is 20MB. The base foot print of CVM is under 2MB ... let's say it's 2MB. Let's say each servlet needs 4MB of memory to run. Hence, each instance of JavaSE running a servlet takes about 24MB of RAM. Each instance of CVM running a servlet takes about 6MB of RAM. Since the device has 4GB of RAM, at any given time, it can hold about 170 instances of JavaSE, or it can hold about 682 instances of CVM ... that is if you don't want to deal with hard disk paging. Which one do you think will be more responsive to the 1000 service requests that is coming in at any given moment? I'm not going to answer that. ;-) The answer is not as clear cut as you think. Obviously, just by looking at the device capability alone, you may not be making the best decision. On the other hand, the solution needs JavaEE compliance. CVM is fully compliant with the 2nd edition Java VM specification. Hence, you can run a JavaSE and JavaEE stack on top of it. But hey, wouldn't that increase CVM's foot print to more than just 2MB? Yes, it will. I don't actually have the VM footprint numbers for JavaSE. My example is contrived, but it may not be invalid. Regardless, it does illustrate my point that, sometimes, things aren't always as they seem. There are many factors to consider. Certainly, hardware / device capability isn't the only important factor. What does this mean to you? Have a nice day, and for those in the US, have a Happy Thanksgiving. :-) »
Related Topics >>
Mobile and Embedded Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|