[
https://issues.apache.org/jira/browse/THRIFT-10?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606660#action_12606660
]
Johan Stuyts commented on THRIFT-10:
------------------------------------
I doubt if making the members final will have any effect on the performance.
The compiler and runtime are very smart (as I found out again). When I run the
benchmark, with memory limited to 16 MB to force garbage collection to occur
during the benchmark, I only get a performance improvement of less than 6 %.
And the only thing the benchmark actually does besides serializing structs is
counting the number of bytes that are written. In production environments the
improvement will probably be immeasurable. You would expect that instantiating
millions of objects, initializing their fields and garbage collecting them
would consume more time.
Here are the numbers:
- without the patch (ms): 2093, 2094, 2110, 2110, 2093
- with the patch (ms): 2015, 1968, 1984, 1969, 1985
I removed the highest and lowest measurement from each set, added the remaining
three measurements and divided the results:
- without the patch (ms): 2093 + 2094 + 2110 = 6297
- with the patch (ms): 1984 + 1969 + 1985 = 5938
- divided: 5938 / 6297 = 0,943 = 5,7 % improvement
> Descriptors used during serialization should be immutable objects
> -----------------------------------------------------------------
>
> Key: THRIFT-10
> URL: https://issues.apache.org/jira/browse/THRIFT-10
> Project: Thrift
> Issue Type: Improvement
> Components: Library (Java)
> Reporter: Johan Stuyts
> Priority: Minor
> Attachments: ImmutableProtocolComponentDescriptors2.patch,
> SerializationBenchmarkMain.java
>
>
> The descriptors for structures, messages, types, etc. in package
> {{com.facebook.thrift.protocol}} which are used during (de-)serialization
> have mutable attributes. This forces the creation of these descriptors for
> each use even if the data is constant in many cases.
> By changing the descriptors to be immutable, structures and protocols can use
> singleton, constant instances during (de-)serialization. This will improve
> performance a bit by preventing the creation of hundreds (thousands?) of
> short-lived objects per second during heavy use of Thrift.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.