Skip to content

Commit

Permalink
storage: change map type for _db in kvstore
Browse files Browse the repository at this point in the history
In an effort to move to fragmented data structures, the `absl::btree_map`
type used in the `kvstore` is now replaced by a `chunked_hash_map`.

We do not rely on the ordering or any sort of pointer/reference/iterator
stability provided by `absl::btree_map` in our current uses of `_db`, so
this is a painless swap.
  • Loading branch information
WillemKauf committed May 15, 2024
1 parent 2af7c72 commit 85fe2a3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/v/storage/kvstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

#pragma once
#include "base/seastarx.h"
#include "bytes/bytes.h"
#include "bytes/iobuf.h"
#include "container/chunked_hash_map.h"
#include "metrics/metrics.h"
#include "storage/fwd.h"
#include "storage/ntp_config.h"
Expand Down Expand Up @@ -91,6 +93,8 @@ struct kvstore_config {

class kvstore {
public:
using map_t = chunked_hash_map<bytes, iobuf>;

enum class key_space : int8_t {
testing = 0,
consensus = 1,
Expand Down Expand Up @@ -164,7 +168,7 @@ class kvstore {
// Protect _db and _next_offset across asynchronous mutations.
mutex _db_mut{"kvstore::db_mut"};
model::offset _next_offset;
absl::btree_map<bytes, iobuf, bytes_type_cmp> _db;
map_t _db;
std::optional<ntp_sanitizer_config> _ntp_sanitizer_config;

ss::future<> put(key_space ks, bytes key, std::optional<iobuf> value);
Expand Down

0 comments on commit 85fe2a3

Please sign in to comment.