Skip to content

Optimize Range WithKeysOnly to avoid loading values in memory #20386

@serathius

Description

@serathius

What would you like to be added?

Kubernetes 1.34 will start using Range WithKeysOnly. Main reason to use this method is to reduce the overhead of loading values in memory when they are not needed. While using WithKeysOnly avoids transferring them to client, it doesn't help with etcd memory

Noticed that it loads values in memory just to throw them out little later:

if r.KeysOnly {
rr.KVs[i].Value = nil
}

TODO:

  • Add thorough range tests we don't break it.
  • Identify places that use value in etcd server. For example when sorting by value
  • Implement support for KeysOnly method for keyindex
  • Use KeysOnly method when we don't need value, like when we don't sort by it.
  • Benchmark to show improvement

Please note this task is complicated and not good for first contributor.

Why is this needed?

Align with user expectation that using WithKeysOnly is more efficient on server.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions