• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization Vs Externalisation

 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How does the performance effect on Externalisation over Serialization.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Externalization allows you to customize how serialization is done. By implementing externalization you are controlling what gets serialized ( and what doesnot ) as versus default serialization where all non-transient attributes get serialized.
For "fat data" classes with a large number of attributes only a few of which needs to persisted, externalization will help you reduce the size of serialized stream and the time taken to serialize the object. But there will be an overhead involved because the runtime has to call your methods to read/write objects.
This is all I can think of, nothing else comes to my mind in terms of performance benefits. Anyone??

------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java2 Platform.
 
Kartik Shah
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Further more if you are subclassing your externalizable class you will want to invoke your superclass's implementation. So this causes overhead while you subclass your externalizable class.
2. methods in externalizable interface are public. So any malicious program can invoke which results into lossing the prior serialized state.
 
Jack Shirazi
Author
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajith wrote:
"But there will be an overhead involved because the runtime has to call your methods to read/write objects."
Serialization has huge overheads in having to paw through private stuff via the JVM that is normally unavailable, and also with all the reflection it uses. Externalization is a simple method call.
There is no overhead to the calls to your methods, it normally works out faster. Perverse, but true.
--Jack http://www.JavaPerformanceTuning.com/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic