SOLR-18315: Optimize UTF conversions by using standard Java APIs - #4653
SOLR-18315: Optimize UTF conversions by using standard Java APIs#4653psalagnac wants to merge 2 commits into
Conversation
| public static class BenchState { | ||
|
|
||
| @Param({"xml", "binary"}) | ||
| @Param({"xml", "javabin"}) |
There was a problem hiding this comment.
Bug fix here? Nice to see the benchmarks get used and therefore finding oversights like this.
There was a problem hiding this comment.
Yes, bug fix. I added this benchmark a while ago and I assume I forgot to change this name before merging. If I recall well, the class was renamed while I was working on this.
There was a problem hiding this comment.
cool! thanks for responding.
|
I reviewed the code. I had suspicions the historic developments that lead to it's current state had insights that the change here reverts. I had Claude review and it came up with the following report: Reviewed the write-side changes in Potential infinite loop on malformed UTF-16 input The double-pass encode at while (!endOfInput) {
endOfInput = !cb.hasRemaining();
scratch.clear();
encoder.encode(cb, scratch, endOfInput); // result discarded
sz += scratch.position();
}The default The deleted
Suggested fix: check the Two smaller, lower-confidence points:
IMO the allocation is probably a non-issue as I assume it'd be stack-allocated -- the JVM is very smart |
https://issues.apache.org/jira/browse/SOLR-18315
Description
This replaces class
ByteUtilsby Java API calls, mostlyStringconstructor andgetBytes()method when doing short-lengthbyte[] <-> Stringconversions, or usingCharsetEncoderfor longer data.Tests
I validated the perf improvement with
RequestWritersbenchmark (note it just measures serialization of update requests, whithout processing the requests).I get a 8.5x improvement in throughput.