valkey-io / valkey

A flexible distributed key-value datastore that is optimized for caching and other realtime workloads.
https://valkey.io
Other
17.75k stars 673 forks source link

Moving client->authenticated to a flag instead of an int #589

Closed madolson closed 5 months ago

madolson commented 6 months ago

We periodically check client->authenticated to see if the client authenticated with the current user, or was just assuming the default user for backwards compatibility. This check is fine, however it's unnecessary to use 4 bytes for what is basically a single bit flag. We can save the entire 4 bytes by moving it to a flag like https://github.com/valkey-io/valkey/blob/417660449f9c1fce998e1563f30f7bfd9cb5197f/src/server.h#L429.

Doing so would save some memory and might reduce cache line misses.

Dev-Arhaan commented 6 months ago

Hi I would like to contribute, can you elaborate on this solution You're proposing a bit more?