-
Notifications
You must be signed in to change notification settings - Fork 797
Performance: Reuse ServerCallContext #369
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
Comments
I think reusing ServerCallContext makes sense if it can be done safely. We'd need this
|
Looking at the ServerCallContext members, I'm not sure how many of them could be reused profitably.
I think it would be good to first have some solid benchmarks and then look into this optimization in a data-centric way. |
Reusable:
|
Tried this out using IPersistentStateFeature in .NET 6 and it wasn't worth it. The context is too small to make up for the overhead of getting the context from a dictionary and reset all the state. |
Uh oh!
There was an error while loading. Please reload this page.
HttpContextServerCallContext is currently created every call. If we make the context reusable (like HttpContext now is) then we can reset and reuse it between call. That would allow us to cache other per-call objects on it like the reader, writer, serialization context, etc, and save allocating those per-call as well.
Questions:
The text was updated successfully, but these errors were encountered: