Re: java serialization alternative
Jeff Kesselman <[email protected]> Sat, 29 Mar 2008 15:11:01 -0400
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
A dissenting view Theres a lot of mythology arpound Java Serialization. The fact of the matter is that, for the kind of system it is, if you need all it capabilities, its about as effecieint as anything else your likely to build. Provided you use it right. We use Java serialization in Darkstar and get object accesses, which inbclused both serialization/deserialization and databsase acess) in the low tenths of ms. (Thats tenths, not tens.) It is very easy to over-serialize by not properly pruning your object graph. You need to be actively aware of what data you are really trying to communicate and make efective use of Transient fields to trim the graph. Keep in mind that you can use Java serialization and take control of the actual representations of individual objects if you wish at multiple levels (the most extreme case being using Externalizable to take total control threof.) IMO the question you reallu need tpo ask is, is object level communication really what you want? if all you are doing is pushing well known messages around then a byte packet protocol is always going to be more efficient and is trivial to implement in Java, A *sperate* question you need to ask is if RMI is appropriate. RMI is a synchronous protocol. It blocks until the foreign call completes. This means you are paying 2-way latency costs for each call and making your code synchronous where aynchronicity might be more efficient. FInally, you strtaed all this with "I suspect that..." Why do you suspect that? Have you actually profiled and mesured costs? If not then this counts as premature optimization asn is likely as not a total waste of time. -- ======================================================================= Journalism 101: The difference between news and a press release News tells you what the reporter thinks is true. A press release tells you what a company wants *you* to think is true. Only bad reporters think the two are the same. =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com