[
https://issues.apache.org/jira/browse/THRIFT-765?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Muir updated THRIFT-765:
-------------------------------
Attachment: THRIFT-765.patch
just found this issue randomly, late to the game.
I don't think you should give up here, besides the performance problems,
there are also bugs in Sun (and other JDK) UTF-8 implementations.
Included in the patch is a commented-out test showing a bug in my
Sun JDK's UTF-8 decode (1.6.0_19), just as an example.
This patch includes bulk UTF-8 encode/decode with full error-checking.
Ensuring correctness doesn't need to be slow:
* For encode its trivial: just surrogate validation
* For decode its tricky, but the code can be simple with a DFA.
I used the DFA approach here: http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
In my opinion, its the only way to go without a lot of complexity.
I implemented as char[] -> byte[] and back, and throw a checked
CharacterCodingException on invalid inputs.
I didn't modify any thrift code to actually use this, except the benchmark
from the previous patch.
Hopefully its easy adjust to your needs.
> Improved string encoding and decoding performance
> -------------------------------------------------
>
> Key: THRIFT-765
> URL: https://issues.apache.org/jira/browse/THRIFT-765
> Project: Thrift
> Issue Type: Improvement
> Components: Java - Library
> Affects Versions: 0.2
> Reporter: Bryan Duxbury
> Assignee: Bryan Duxbury
> Fix For: 0.4
>
> Attachments: thrift-765-redux-v2.patch, thrift-765-redux.patch,
> THRIFT-765.patch, thrift-765.patch
>
>
> One of the most consistent time-consuming spots of Thrift serialization and
> deserialization is string encoding. For some inscrutable reason,
> String.getBytes("UTF-8") is slow.
> However, it's recently been brought to my attention that DataOutputStream's
> writeUTF method has a faster implementation of UTF-8 encoding and decoding.
> We should use this style of encoding.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.