Viewed 237 times
Load Testing Java Serialization performance. Load testing Java Serialization performance is not an easy matter as requests and responses are binary. In order to make your load test realistic and useful, you always have to variabilize the requests and extract data from responses.
Java Custom Serialization
I'm overriding the writeObject method for a class for serialization.The class is a list based class.I need to make it memory efficient for the case that Nodes in the list contain the same keys.So instead of sending over multiple keys that are identical I want to send over references to the same keys.
My basic goal is to make sure I don't write out duplicate keys. If there are duplicate keys I want to make sure I only send out a key once and then only send out references to it afterwards.
This is the code that I have working correctly for serializing the data. I've tried to make a list of all unique keys and attempted to have each node reference one of those keys, but I haven't been able to get the file size down when I write out.
Also ideally I would like to make the references inside of this method so I only have to worry about doing it before writing out instead of maintaining them during adding/removing.
Any help would be greatly appreciated!
Andrew_CS
Andrew_CSAndrew_CS2,22011 gold badge1111 silver badges3030 bronze badges
Browse other questions tagged javaperformanceserializationmemory-efficient or ask your own question.
Active1 year, 11 months ago
![Java Java](/uploads/1/2/4/8/124805367/395626140.jpg)
I need to deep-copy Java objects for one of my projects; and I was wondering if it's okay to use Serialization for this.
The objects are fairly small (< 1kb each), total #objects per copy would be < 500, and the copy routine will be invoked a few times a day. In this case, will it be okay to use Serialization for this in production, or is that still a really bad idea given the performance of Serialization?
Photoimpact 10 windows 7. PhotoImpact X3 13.0 free download works on windows 10, windows 8.1, Windows 8.Free Ulead Photoimpact 10 Download. Photoimpact X3 For Windows 10 photoimpactThanks for.
If it's still a bad idea, I can think of using copy constructor/static copy method per such class to improve performance. Are there any other ways for it?
shrini1000shrini10003,5391010 gold badges4646 silver badges9393 bronze badges
1 Answer
Maybe. Performance will not be an issue - dependencies will be.
The usual problem with serialization is that an innocent reference to some core class in your application can give you a copy of 90% of all the life instances because they suddenly become reachable. So you must be really careful with
transient
and the references which you use.Worse, if you need serialization for deep copy and real state saving, you might end up with incompatible goals:
- Deep copy needs to be fast
- Deep copy can handle open resources (database connections)
- State saving needs to handle API evolution (the state is stored on disk, it could be restored with a new version of the code).
- State saving can benefit from using a readable form (so a human could fix mistakes)
Therefore, it's often better to use copy constructors than using a 'clever hack' even though it might safe you some/a lot of time right now.
Aaron DigullaJava Serialization Performance Group
Aaron Digulla258k8888 gold badges494494 silver badges724724 bronze badges