-
Notifications
You must be signed in to change notification settings - Fork 5
performance improvement for ReadUvarint() #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Since Golang compilers don't allow us to unroll automatically, here's this method even more optimized. Most of the variables are not really necessary:
|
Testing shows that the unrolled version cut the time spent inside a mutex by 30-60% |
Your first version is faster (~20%) but the loop unrolling didn't seem to help. In general, loop unrolling only helps with tight loops. In this case, the indirect call to |
This speeds up decoding by about 20%. Suggested by @jwinkler2083233 in Fixes #14.
This speeds up decoding by about 20%. Suggested by @jwinkler2083233 in Fixes #14.
This speeds up decoding by about 20%. Suggested by @jwinkler2083233 in Fixes #14.
This ReadUvarint() method is time-sensitive, because it's running inside a mutex. It's called very often.
I'd like to offer a more performant version, that will improve latencies:
Previous version:
New version:
The 'i == 8' is replaced with 's == 56'. MaxLenUvarint63 is '9', currently, so that's not an overflow problem.
This change removes the unnecessary addition operation for 'i'.
The text was updated successfully, but these errors were encountered: