OPTIMIZE: Change ServerBaseContext #137
Merged
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.
Upon transitioning our production services to ServerBaseContext, we saw a serious regression with performance. It wasn't obvious, but I was able to narrow it down to a mysterious solution. Here's a gist of a reproducible benchmark:
https://gist.github.com/cyx/8730ab8d31996711110d9979d1715f98
Long story short, it seems if we create a copy of the base context, then we don't see this performance regression.
I'm open to discuss this some more -- and I've already picked the brains of other Go programmers in our company to see what they think. Logic dictates the copy doesn't do anything, but empirical data shows it does.
Thought this will be useful for others.