Small GenerateOperationId optimization#590
Open
Inok wants to merge 3 commits intoZiggyCreatures:mainfrom
Open
Conversation
Contributor
Author
|
And I also noticed that |
Collaborator
|
Hi @Inok and thanks for the PR! Will look at it in the next few days, but it already looks good. |
This file contains hidden or 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
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.
Hi!
I noticed that
GenerateOperationIdis called in almost every operation on the cache. I optimized the implementation a bit:char[]dictionary (replacing toconst stringhelps the compiler to figure out that boundary checks are not needed).ThreadLocalbuffer tostackalloc char[13]onnetstandard2.0(slightly cheaper and has no boundary checks as well).string.Create()onnet8.0+to build the string in place rather than build a buffer and then copy it to the string.Results:
netstandard2.0version became slightly faster, but no big difference.net8.0version is ~30% faster.@jodydonetti what do you think?