-
Notifications
You must be signed in to change notification settings - Fork 5
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
Optimization #18
Open
stokito
wants to merge
17
commits into
benjaminch:master
Choose a base branch
from
stokito:optimization
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Optimization #18
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The logging is almost useless for users but a developer can debug in IDE. The raw keys bytes are not saying anything. We have errors to return a message to a caller. In the same time the code needs to be compiled and it makes the program slower because it resides in CPU cache.
Remove deprecated isDebugMode
These fields are never read but consumes memory. If we are going to create many instances of the Pricer then it will consume a lot of memory and make program slower
The function will decode the string key
You can decode the keys one and then create multiple pricers with them.
It will never occur. Even seed is just an empty string the md5 hash will be not empty
The method accepts a price in raw bytes. It also receives a buffer for decoding which can be reused later
It can be pre-allocated. This saved one allocation and improved speed
The generated assembly has a cycle to make xor with two arrays p and pad. Given that the two arrays have only 8 bytes we can convert them to uint64 and perform a usual xor. The optimization makes code harder to read and saves only about 4ns.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I going to reuse a pricer instances and put them to a sync.Pool
In the same time I receiving the encryptedPrice as []byte so on conversion to string it creates an allocation.
Here I extracted a separate method DecodeRaw() that can work directly with []byte.
But also it can reuse a buffer and count of allocations significantly reduced.
Under a heavy load this is a very good thing