Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Stop allocating strings for every ParameterStatus message #2236
When a connection parameter changes, PostgreSQL sends a ParameterStatus to notify the client. It turns out that when we do
The parameter names can probably be interned (very short list), and for the value we can simply check if there was a change compared to the current value.
It could help. However... The point of parameters is also to have a key-value dictionary which can be consulted at any time to get the state of any parameter - both by Npgsql internal, and by external users: we expose a read-only
But I think this is pretty easy to solve regardless of Span... As long as we cache the byte representation of a parameter somewhere, we can compare incoming values in ParameterStatus against the cache, and if there's no change, we do nothing at all. If there is one, we can pay the allocation cost and have a string as usual - I think that should be very acceptable. The main goal IMHO is to avoid allocations when the parameter value does not change.