Interface exposes only array based interface which requires external allocations of arrays
In high performance code one might want to reduce allocations to minimum and pre-allocate/reuse the memory needed. Currently with the API which directly exposes raw arrays this is not possible. I would suggest adding/changing the APIs like:
void HashSet(RedisKey key, HashEntry[] hashFields, CommandFlags flags = CommandFlags.None);
something like
void HashSet(RedisKey key, Memory<HashEntry> hashFields, CommandFlags flags = CommandFlags.None);
or maybe even:
void HashSet(RedisKey key, Span<HashEntry> hashFields, CommandFlags flags = CommandFlags.None);
We're aware. The problem is doing this without causing an API explosion, since we would have to add overloads, not change existing signatures.
We should probably do a pass at what the reasonable set of high-usage APIs is here; GET, HGET, etc. I wouldn't propose tweaking every single array usage - but certainly key ones have merit.
On Thu, 17 Nov 2022, 14:55 Greg Ravikovich, @.***> wrote:
In high performance code one might want to reduce allocations to minimum and pre-allocate/reuse the memory needed. Currently with the API which directly exposes raw arrays this is not possible. I would suggest adding/changing the APIs like:
void HashSet(RedisKey key, HashEntry[] hashFields, CommandFlags flags = CommandFlags.None);
something like
void HashSet(RedisKey key, Memory<HashEntry> hashFields, CommandFlags flags = CommandFlags.None);
or maybe even:
void HashSet(RedisKey key, Span<HashEntry> hashFields, CommandFlags flags = CommandFlags.None);
— Reply to this email directly, view it on GitHub https://github.com/StackExchange/StackExchange.Redis/issues/2305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEHMGLSN5776ION72QGVTWIZBPTANCNFSM6AAAAAASDO6MSM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Any Progress?
causing an API explosion
It's not a problem since dotnet/runtime has been adding more and more ReadOnlySpan overloads, too. It also won't bring too much maintenance burden.
not change existing signatures
I don't know how big the impact will be. But as a user and community member, I'd like to see this issue move forward.