-
Notifications
You must be signed in to change notification settings - Fork 608
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
Reduce sprintf overhead in code showing up during sync profiles #7182
Conversation
x/poolmanager/types/keys.go
Outdated
@@ -43,7 +44,16 @@ var ( | |||
|
|||
// ModuleRouteToBytes serializes moduleRoute to bytes. | |||
func FormatModuleRouteKey(poolId uint64) []byte { | |||
return []byte(fmt.Sprintf("%s%d", SwapModuleRouterPrefix, poolId)) | |||
// Estimate the length of the string representation of poolId | |||
// 7 is a safe upper bound, (9999999) pools, and is an 8 byte allocation (not bad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for extra safety... should we check that poolId < 9999999?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All we could really do is panic, which is what will already happen here anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add that check to CreatePool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok just raised the upperbound to 99,999,999,999
. At $1 to create a pool, this is a third the market cap of ETH, so going to go ahead and merge!
Added check for it in #7203 |
* Reduce sprintf overhead in code showing up during sync profiles * Raise upperbound to not worry about it (cherry picked from commit cb9cb4e)
… (#7204) * Reduce sprintf overhead in code showing up during sync profiles * Raise upperbound to not worry about it (cherry picked from commit cb9cb4e) Co-authored-by: Dev Ojha <[email protected]>
… (#7204) * Reduce sprintf overhead in code showing up during sync profiles * Raise upperbound to not worry about it (cherry picked from commit cb9cb4e) Co-authored-by: Dev Ojha <[email protected]>
Reduce some sprintf overheads
This is a pretty micro-optimization. It likely has more impact for txs than epoch. In epoch it shaves like 100ms (there are way better things to shave time on there)