Pre-cache the services by name dictionary. #931
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.
Motivation:
Currently whenever we construct the GRPCServerRequestRoutingHandler we
need to give it a dictionary of services by name. This is currently done
via a computed property. The result of that is that we compute this
dictionary on the fly every time we receive a new RPC, which is not
exactly the most efficient usage model.
Instead, we should just calculate this ahead of time and save the thing
we actually want, which is the Dictionary. As this data structure is
read vastly more often than it is written, this ends up being a
minor performance win in basically all server applications.
A note: technically this is very subtly breaking as it no longer
guarantees that the Array containing the Services will be in the same
order when you read it as when you set it. I think this is acceptable:
the odds that anyone will rely on this behaviour is low. If we'd minted
1.0.0 I wouldn't take the risk, but right now I think it's ok to take it
and just document our way out of it.
Modifications:
name.
Results:
Minor performance improvement.