kidok / protobuf

Automatically exported from code.google.com/p/protobuf
0 stars 0 forks source link

performance enhancement: use String#getBytes(Charset) instead of getBytes(String) #559

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

https://code.google.com/p/protobuf/source/browse/trunk/java/src/main/java/com/go
ogle/protobuf/ByteString.java?r=349#135

when encoding strings to bytes, ByteString should use the more recent 
String#getBytes(Charset) call, which has less overhead (~10% improvement).

Original issue reported on code.google.com by phraktle on 17 Sep 2013 at 5:02

GoogleCodeExporter commented 9 years ago
Can you share more information on the benchmarks you use? ~10% sounds very 
impressive but it depends on how you benchmark it.

Original comment by xiaof...@google.com on 17 Sep 2013 at 7:08

GoogleCodeExporter commented 9 years ago

The benchmark was a Caliper test comparing String#getBytes(Charset) vs 
String#getBytes(String). How this translates into overall improvements depends 
on what portion of the protobufs in the workload consist of Strings (quite a 
lot in our use-case).

Original comment by phraktle on 18 Sep 2013 at 11:01

GoogleCodeExporter commented 9 years ago
How large is the String in your benchmark? I expect the performance improvement 
ratio differs for different sizes of Strings as the overhead of retrieving 
Charset from its name is constant.

Original comment by xiaof...@google.com on 18 Sep 2013 at 5:38

GoogleCodeExporter commented 9 years ago
Indeed, the returns are diminishing with longer strings. But there's no 
downside :)

n   diff
1    15%
10   10%
100   5%
1000  1%

Original comment by phraktle on 18 Sep 2013 at 6:23

GoogleCodeExporter commented 9 years ago
Are there plans to incorporate this?

Original comment by phraktle on 25 Oct 2013 at 7:19

GoogleCodeExporter commented 9 years ago
We'll fix accepted issues before next release, which probably will come early 
2014. You can submit a patch if you'd like get it fixed in trunk sooner than  
that.

Original comment by xiaof...@google.com on 25 Oct 2013 at 5:12

GoogleCodeExporter commented 9 years ago
Is this project dead?  I am seeing zero activity on the code base since last 
April?  there are tons of great patches and suggestions on this issues page and 
none of them seem to be acted upon?  Can we get a roadmap?

Original comment by mellowaredev on 19 Dec 2013 at 4:21

GoogleCodeExporter commented 9 years ago
We have been working on this project actively inside Google, but you won't see 
much activity here until we start to make another open-source release, 

Original comment by xiaof...@google.com on 23 Dec 2013 at 12:39

GoogleCodeExporter commented 9 years ago
We have been working on this project actively inside Google, but you won't see 
much activity here until we start to make another open-source release, 

Original comment by xiaof...@google.com on 23 Dec 2013 at 12:39

GoogleCodeExporter commented 9 years ago
Excellent thanks for the update!

Original comment by mellowaredev on 23 Dec 2013 at 12:41