-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve storage lookup performance #7336
Improve storage lookup performance #7336
Conversation
b062332
to
a7a48de
Compare
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.
👍
return &storage.Error{ | ||
Code: storage.NotFoundErr, | ||
Message: message, | ||
} |
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.
This is a performance optimization?
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, saw the benchtest 👍
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.
Yeah, it's quite insidious how much Sprintf can cost even in simple cases!
sb.Grow(l) | ||
for i := range p { | ||
sb.WriteByte('/') | ||
sb.WriteString(url.PathEscape(p[i])) |
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.
If this causes escaping, I suppose the only ill effect is that the above sb.Grow(l)
wasn't enough and sb
needs to grow further?
Since you're interested in performance in this PR, I assume you've confirmed this is better or equal in performance compared to the old method for the general/common case. How about the worst case, where sb
needs to grow further (maybe more than once)?
Some code I had left from the weekend, where I looked into the cost of querying the store during eval, and if that could be improved. The code here is mostly benchmarks that I found useful for that purpose, but also includes a few optimizations of code that is on the hot path for these lookups and as such has a high impact — as the benchmarks demonstrate. The small change in eval.go is the first use of the new feature of object.Map added some days ago, where a map function returning a nil key means skipping that key/value pair. Signed-off-by: Anders Eknert <[email protected]>
a7a48de
to
efab512
Compare
Some code I had left from the weekend, where I looked into the cost of querying the store during eval, and if that could be improved. The code here is mostly benchmarks that I found useful for that purpose, but also includes a few optimizations of code that is on the hot path for these lookups and as such has a high impact — as the benchmarks demonstrate.
The small change in eval.go is the first use of the new feature of object.Map added some days ago, where a map function returning a nil key means skipping that key/value pair.