New option: reuse-objects for Java generator#81
New option: reuse-objects for Java generator#81adam-aph wants to merge 1 commit intoapache:masterfrom
Conversation
|
Hi Adam, thanks for the request. |
|
Hi Henrique - I think this new parameter would be required - the patch is not breaking existing code, however it may reveal issues in existing applications (currently the deserialization delivers always newly allocated objects, but when the re-use is switched on, the application needs to remember to properly "clean" all storage objects, otherwise subsequent deserializations will be added on the top of previous ones. |
|
in this case we should have at least unit-tests demonstrating, and testing, the correct usage. |
|
unfortunatelly you are right ;) |
|
That would be great Adam! |
|
ok, I added unit tests for this new option please let me know how do you like these changes. |
|
Build triggered. Test FAILed. |
|
closing per THRIFT-2368 |
https://issues.apache.org/jira/browse/THRIFT-2368
For applications serializing and deserializing millions of transactions it is important to avoid unnecessary memory allocations - the allocated and abandoned objects needs to be collected and deleted by GC, which creates "stop-the-world" pauses. The new compiler option forces thrift compiler to generate code which is reusing existing objects for deserialization (this is up to caller to make sure that read data will fit). Without that option compiler generates the same code as originally.
code generated by original compiler (0.9.1):
code generated with enabled "java:reuse-objects" option: