Repository navigation
chore(store): store.v1LegacyLayout no longer uses fmt.Sprintf() to create DB keys. - #4489
Merged
Merged
Conversation
store.v1LegacyLayout no longer uses fmt.Sprintf() to create DB keys.store.v1LegacyLayout no longer uses fmt.Sprintf() to create DB keys.
added 14 commits
November 13, 2024 18:22
It now encodes to hex the `hash` it receives as argument as the prev version did.
After benchmarking, I found that while extracting the helper method reduces code duplication, it negatively affects performance. This is because `buildKey` allocates the `key` slice using a calculated expression: `make([]byte, 0, len(prefix)+20)`. Since the compiler cannot determine `len(prefix)` at compile time, it likely allocates extra memory for the slice. This reverts commit 8fd2f36.
The compiler will recognize the slice's capacity as a compile-time constant and apply optimizations that avoid unnecessary allocations.
Improves readability a bit.
alesforz
marked this pull request as ready for review
November 14, 2024 15:21
3 tasks done
jmalicevic
approved these changes
Nov 14, 2024
alesforz
added this pull request to the merge queue
Nov 15, 2024
Collaborator
Author
|
Note: the changes in this PR are superseded by #4490. |
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.
The
v1LegacyLayouttype of pkgstoreusesfmt.Sprintf()to create the DB keys.This PR refactors functions using
fmt.Sprintfto improve their speed and memory usage.PR checklist
.changelog(we use unclog to manage our changelog)docs/orspec/) and code comments