You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by Hendrik Dev <he...@gmail.com> on 2014/06/28 23:01:41 UTC

Some suggestions for Strings.java and JsonLongImpl.java

only constants in escape() method, unicode cache, clean up of possibly
unnecessary code
https://github.com/salyh/fleece_tmp/commit/a8d852bc3beeddc9607af1005a2cfdde2f252230

long is integral
https://github.com/salyh/fleece_tmp/commit/03dc2df406d171ded8db5199d4618786d29e5298

Thanks
Hendrik

Re: Some suggestions for Strings.java and JsonLongImpl.java

Posted by Romain Manni-Bucau <rm...@gmail.com>.
I tried at some point (never pushed) to cache few more things but just
the fact to compute hashcode was longer than doing the direct string
computation so I removed this useless cache level.

Last point please use Map or ConcurrentMap on left side (field type) +
hashmap is not thread safe in this case so use a ConcurrentHashMap
maybe.



Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-07-05 10:11 GMT+02:00 Hendrik Dev <he...@gmail.com>:
> The Strings.java JMH based benchmark i did can be found here
> https://github.com/salyh/fleece_tmp/tree/benchmark-streamparser/fleece-core
>
> avg_benchmark_jmh_result_f2_t16_w3_i5.txt for example shows
>
> Benchmark Mode Samples Score Score error Units
> o.a.f.c.j.b.BenchmarkStringsCompact.normalWithUnicode
> avgt        10   117411,047     6748,646    us/op
> o.a.f.c.j.b.BenchmarkStringsCompact.normalWithoutUnicode
> avgt        10   118481,121    10540,816    us/op
> o.a.f.c.j.b.BenchmarkStringsCompact.optimizedWithUnicode
> avgt        10   102078,601     7623,861    us/op
> o.a.f.c.j.b.BenchmarkStringsCompact.optimizedWithoutUnicode
> avgt        10   125038,896     8359,245    us/op
>
> There is no real improvement if i read the figures correctly.
>
> @romain: BTW what do exactly mean with "slow hashcode computation"?
> hashcode of what?
>
>
> Implementations:
> https://github.com/salyh/fleece_tmp/blob/benchmark-streamparser/fleece-core/src/main/java/org/apache/fleece/core/Strings_Optimized.java
> https://github.com/salyh/fleece_tmp/blob/benchmark-streamparser/fleece-core/src/main/java/org/apache/fleece/core/Strings.java
>
> Thanks
> Hendrik
>
> On Sat, Jun 28, 2014 at 11:58 PM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
>> Ok,
>>
>> thanks a lot for the jira + patch (I know it looks too much for 1 word
>> but makes obvious you contributed the patch ;)).
>>
>> Waiting to read the result of your tests ;)
>>
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>> 2014-06-28 23:36 GMT+02:00 Hendrik Dev <he...@gmail.com>:
>>> jira issue opened
>>>
>>> regarding the figures: i have some measurements on my own and the code
>>> shows a slight speedup, but i will look into
>>> https://github.com/RichardHightower/json-parsers-benchmark
>>>
>>> On Sat, Jun 28, 2014 at 11:16 PM, Romain Manni-Bucau
>>> <rm...@gmail.com> wrote:
>>>> second fix is ok (please open a jira and attach a patch)
>>>>
>>>> the first one need figures (I used
>>>> https://github.com/RichardHightower/json-parsers-benchmark ), last
>>>> time I tried such a thing computing hashcode was too slow.
>>>>
>>>>
>>>> Romain Manni-Bucau
>>>> Twitter: @rmannibucau
>>>> Blog: http://rmannibucau.wordpress.com/
>>>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>>>> Github: https://github.com/rmannibucau
>>>>
>>>>
>>>> 2014-06-28 23:01 GMT+02:00 Hendrik Dev <he...@gmail.com>:
>>>>> only constants in escape() method, unicode cache, clean up of possibly
>>>>> unnecessary code
>>>>> https://github.com/salyh/fleece_tmp/commit/a8d852bc3beeddc9607af1005a2cfdde2f252230
>>>>>
>>>>> long is integral
>>>>> https://github.com/salyh/fleece_tmp/commit/03dc2df406d171ded8db5199d4618786d29e5298
>>>>>
>>>>> Thanks
>>>>> Hendrik
>
>
>
> --
> Hendrik Saly (salyh, hendrikdev22)
> @hendrikdev22
> PGP: 0x22D7F6EC

Re: Some suggestions for Strings.java and JsonLongImpl.java

Posted by Hendrik Dev <he...@gmail.com>.
The Strings.java JMH based benchmark i did can be found here
https://github.com/salyh/fleece_tmp/tree/benchmark-streamparser/fleece-core

avg_benchmark_jmh_result_f2_t16_w3_i5.txt for example shows

Benchmark Mode Samples Score Score error Units
o.a.f.c.j.b.BenchmarkStringsCompact.normalWithUnicode
avgt        10   117411,047     6748,646    us/op
o.a.f.c.j.b.BenchmarkStringsCompact.normalWithoutUnicode
avgt        10   118481,121    10540,816    us/op
o.a.f.c.j.b.BenchmarkStringsCompact.optimizedWithUnicode
avgt        10   102078,601     7623,861    us/op
o.a.f.c.j.b.BenchmarkStringsCompact.optimizedWithoutUnicode
avgt        10   125038,896     8359,245    us/op

There is no real improvement if i read the figures correctly.

@romain: BTW what do exactly mean with "slow hashcode computation"?
hashcode of what?


Implementations:
https://github.com/salyh/fleece_tmp/blob/benchmark-streamparser/fleece-core/src/main/java/org/apache/fleece/core/Strings_Optimized.java
https://github.com/salyh/fleece_tmp/blob/benchmark-streamparser/fleece-core/src/main/java/org/apache/fleece/core/Strings.java

Thanks
Hendrik

On Sat, Jun 28, 2014 at 11:58 PM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> Ok,
>
> thanks a lot for the jira + patch (I know it looks too much for 1 word
> but makes obvious you contributed the patch ;)).
>
> Waiting to read the result of your tests ;)
>
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-06-28 23:36 GMT+02:00 Hendrik Dev <he...@gmail.com>:
>> jira issue opened
>>
>> regarding the figures: i have some measurements on my own and the code
>> shows a slight speedup, but i will look into
>> https://github.com/RichardHightower/json-parsers-benchmark
>>
>> On Sat, Jun 28, 2014 at 11:16 PM, Romain Manni-Bucau
>> <rm...@gmail.com> wrote:
>>> second fix is ok (please open a jira and attach a patch)
>>>
>>> the first one need figures (I used
>>> https://github.com/RichardHightower/json-parsers-benchmark ), last
>>> time I tried such a thing computing hashcode was too slow.
>>>
>>>
>>> Romain Manni-Bucau
>>> Twitter: @rmannibucau
>>> Blog: http://rmannibucau.wordpress.com/
>>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>>> Github: https://github.com/rmannibucau
>>>
>>>
>>> 2014-06-28 23:01 GMT+02:00 Hendrik Dev <he...@gmail.com>:
>>>> only constants in escape() method, unicode cache, clean up of possibly
>>>> unnecessary code
>>>> https://github.com/salyh/fleece_tmp/commit/a8d852bc3beeddc9607af1005a2cfdde2f252230
>>>>
>>>> long is integral
>>>> https://github.com/salyh/fleece_tmp/commit/03dc2df406d171ded8db5199d4618786d29e5298
>>>>
>>>> Thanks
>>>> Hendrik



-- 
Hendrik Saly (salyh, hendrikdev22)
@hendrikdev22
PGP: 0x22D7F6EC

Re: Some suggestions for Strings.java and JsonLongImpl.java

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Ok,

thanks a lot for the jira + patch (I know it looks too much for 1 word
but makes obvious you contributed the patch ;)).

Waiting to read the result of your tests ;)



Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-06-28 23:36 GMT+02:00 Hendrik Dev <he...@gmail.com>:
> jira issue opened
>
> regarding the figures: i have some measurements on my own and the code
> shows a slight speedup, but i will look into
> https://github.com/RichardHightower/json-parsers-benchmark
>
> On Sat, Jun 28, 2014 at 11:16 PM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
>> second fix is ok (please open a jira and attach a patch)
>>
>> the first one need figures (I used
>> https://github.com/RichardHightower/json-parsers-benchmark ), last
>> time I tried such a thing computing hashcode was too slow.
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>> 2014-06-28 23:01 GMT+02:00 Hendrik Dev <he...@gmail.com>:
>>> only constants in escape() method, unicode cache, clean up of possibly
>>> unnecessary code
>>> https://github.com/salyh/fleece_tmp/commit/a8d852bc3beeddc9607af1005a2cfdde2f252230
>>>
>>> long is integral
>>> https://github.com/salyh/fleece_tmp/commit/03dc2df406d171ded8db5199d4618786d29e5298
>>>
>>> Thanks
>>> Hendrik

Re: Some suggestions for Strings.java and JsonLongImpl.java

Posted by Hendrik Dev <he...@gmail.com>.
jira issue opened

regarding the figures: i have some measurements on my own and the code
shows a slight speedup, but i will look into
https://github.com/RichardHightower/json-parsers-benchmark

On Sat, Jun 28, 2014 at 11:16 PM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> second fix is ok (please open a jira and attach a patch)
>
> the first one need figures (I used
> https://github.com/RichardHightower/json-parsers-benchmark ), last
> time I tried such a thing computing hashcode was too slow.
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-06-28 23:01 GMT+02:00 Hendrik Dev <he...@gmail.com>:
>> only constants in escape() method, unicode cache, clean up of possibly
>> unnecessary code
>> https://github.com/salyh/fleece_tmp/commit/a8d852bc3beeddc9607af1005a2cfdde2f252230
>>
>> long is integral
>> https://github.com/salyh/fleece_tmp/commit/03dc2df406d171ded8db5199d4618786d29e5298
>>
>> Thanks
>> Hendrik

Re: Some suggestions for Strings.java and JsonLongImpl.java

Posted by Romain Manni-Bucau <rm...@gmail.com>.
second fix is ok (please open a jira and attach a patch)

the first one need figures (I used
https://github.com/RichardHightower/json-parsers-benchmark ), last
time I tried such a thing computing hashcode was too slow.


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-06-28 23:01 GMT+02:00 Hendrik Dev <he...@gmail.com>:
> only constants in escape() method, unicode cache, clean up of possibly
> unnecessary code
> https://github.com/salyh/fleece_tmp/commit/a8d852bc3beeddc9607af1005a2cfdde2f252230
>
> long is integral
> https://github.com/salyh/fleece_tmp/commit/03dc2df406d171ded8db5199d4618786d29e5298
>
> Thanks
> Hendrik