[threeten-dev] Ser performance
Xueming Shen
xueming.shen at oracle.com
Wed Mar 6 09:41:29 PST 2013
On 03/06/2013 01:11 AM, Stephen Colebourne wrote:
> See also
> http://blog.joda.org/2010/02/serialization-shared-delegates_9131.html
>
> The format focusses on reducing the size of a single object, by
> reducing the header (short class name Ser), sharing the header (shared
> between all classes in the same package) and an optimal data format
> (although it could be reduced more, 2 byte saving in LocalDate would
> be easy).
>
> Your test averages the message size over 1000 stores, which naturally
> ignores the cost of the header. But its the header cost which
> dominates in typical application messages.
Understood the deliberation of using Ser for the class desp saving. I'm not sure
which user case, bulk data transferring or single date sending/receiving, is more
important in real application world.
> Your test also doesn't place multiple classes from the same package in
> the same stream, say 2 LocalDates, 2 LocalTimes a Period and a
> Duration. The Ser approach should shine there.
>
> Your "simple" version is still quite advanced, using the Unsafe class.
> The simplest serialization would simply be to have no readObject
> writeObject other than for validation.
>
The Unsafe is mainly for the "final" fields, a workaround for that long-waiting rfe
of easy-serialization vs final field.
-Sherman
> I don't understand why LocalTime size would be larger and speed slower
> than the alternative.
>
> Stephen
>
>
>
> On 5 March 2013 23:41, Xueming Shen<xueming.shen at oracle.com> wrote:
>> Just tried a non-scientific performance measurement on the proxy pattern
>> used by the Ser spec/impl, here is the data from the simple benchmark
>> SerTest.java.
>>
>> It appears the
>> (1) expected slowdown is obvious on the serialization side, particular in
>> LocalTime
>> (2) the de-serialization side may be just fine.
>>
>> http://cr.openjdk.java.net/~sherman/jdk8_threeten/serPerm/
>> http://cr.openjdk.java.net/~sherman/jdk8_threeten/serPerm/SerTest.java
>>
>> ---------------------Proxy pattern----------------
>> java SerTest 1000
>> --------LocalDate--------
>> serSize=16
>> Writing: 6655
>> Reading: 3224
>> --------LocalTime--------
>> serSize=17
>> Writing: 6125
>> Reading: 2937
>> --------LocalDateTime--------
>> serSize=23
>> Writing: 6188
>> Reading: 3383
>>
>> ---------------------Simple/direct serialization-------
>> --------LocalDate--------
>> serSize=14
>> Writing: 3418
>> Reading: 3836
>> --------LocalTime--------
>> serSize=13
>> Writing: 2756
>> Reading: 2358
>> --------LocalDateTime--------
>> serSize=22
>> Writing: 3266
>> Reading: 4407
>>
More information about the threeten-dev
mailing list