Conversation
|
Short strings also seem to show some improvement actually: |
|
Here's a more thorough test, shows a bit slower for short strings, much faster for long strings 🤷♂ I did a bit more byte shuffling and maybe got the other validation function to run a bit faster... seems significant but hard to tell if it's due to benchmark just being friendlier to the hardware in this specific case or if it's actually doing less work, we'd have to dig into CPU perf counters to see what's happening here: Overall, the change seem to show a 3% decrease in decoding time, but also shows ~2% less memory allocations, which doesn't really make sense to me and may be the cause of the faster execution. Overall this is probably a no-op change performance-wise, but we get a bug fix :) |
I noticed an off-by-one error in the function checking whether a string contains only printable ASCII characters, where we were including 0x7F instead of excluding it.
I added a test for strings containing
~(0x7F) and fixed the code. For some reason the fix also made the function much faster on long strings it seems:I'll follow up with an update of the JSON benchmark to verify the impact on the code using
ascii.ValidPrint.