Skip to content

Commit

Permalink
653:Remove deprecate use_seek_parallel_threshold_ parmeter in hash_spdb
Browse files Browse the repository at this point in the history
  • Loading branch information
ayulas authored and RoyBenMoshe committed Sep 12, 2023
1 parent 063a70e commit b200e4c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Fix RepeatableThread to work properly with on thread start callback feature (htt

### Bug Fixes
db_bench: fix SeekRandomWriteRandom valid check. Use key and value only after checking iterator is valid.
* spdb memtable: Remove deprecate use_seek_parallel_threshold parmeter (#653)

### Miscellaneous

Expand Down
40 changes: 10 additions & 30 deletions memtable/hash_spdb_rep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,10 @@ void SpdbVectorContainer::SortThread() {
class HashSpdbRep : public MemTableRep {
public:
HashSpdbRep(const MemTableRep::KeyComparator& compare, Allocator* allocator,
size_t bucket_size, bool use_seek_parallel_threshold = false);
size_t bucket_size);

HashSpdbRep(Allocator* allocator, size_t bucket_size);

HashSpdbRep(Allocator* allocator, size_t bucket_size,
bool use_seek_parallel_threshold = false);
void PostCreate(const MemTableRep::KeyComparator& compare,
Allocator* allocator);

Expand Down Expand Up @@ -443,22 +443,17 @@ class HashSpdbRep : public MemTableRep {

private:
SpdbHashTable spdb_hash_table_;
bool use_seek_parallel_threshold_ = false;
std::shared_ptr<SpdbVectorContainer> spdb_vectors_cont_ = nullptr;
};

HashSpdbRep::HashSpdbRep(const MemTableRep::KeyComparator& compare,
Allocator* allocator, size_t bucket_size,
bool use_seek_parallel_threshold)
: HashSpdbRep(allocator, bucket_size, use_seek_parallel_threshold) {
Allocator* allocator, size_t bucket_size)
: HashSpdbRep(allocator, bucket_size) {
spdb_vectors_cont_ = std::make_shared<SpdbVectorContainer>(compare);
}

HashSpdbRep::HashSpdbRep(Allocator* allocator, size_t bucket_size,
bool use_seek_parallel_threshold)
: MemTableRep(allocator),
spdb_hash_table_(bucket_size),
use_seek_parallel_threshold_(use_seek_parallel_threshold) {}
HashSpdbRep::HashSpdbRep(Allocator* allocator, size_t bucket_size)
: MemTableRep(allocator), spdb_hash_table_(bucket_size) {}

void HashSpdbRep::PostCreate(const MemTableRep::KeyComparator& compare,
Allocator* allocator) {
Expand Down Expand Up @@ -522,8 +517,7 @@ void HashSpdbRep::Get(const LookupKey& k, void* callback_args,

MemTableRep::Iterator* HashSpdbRep::GetIterator(Arena* arena) {
const bool empty_iter =
spdb_vectors_cont_->IsEmpty() ||
(use_seek_parallel_threshold_ && !spdb_vectors_cont_->IsReadOnly());
spdb_vectors_cont_->IsEmpty() || !spdb_vectors_cont_->IsReadOnly();
if (arena != nullptr) {
void* mem;
if (empty_iter) {
Expand All @@ -543,7 +537,6 @@ MemTableRep::Iterator* HashSpdbRep::GetIterator(Arena* arena) {
struct HashSpdbRepOptions {
static const char* kName() { return "HashSpdbRepOptions"; }
size_t hash_bucket_count;
bool use_seek_parallel_threshold;
};

static std::unordered_map<std::string, OptionTypeInfo> hash_spdb_factory_info =
Expand All @@ -552,22 +545,12 @@ static std::unordered_map<std::string, OptionTypeInfo> hash_spdb_factory_info =
{offsetof(struct HashSpdbRepOptions, hash_bucket_count),
OptionType::kSizeT, OptionVerificationType::kNormal,
OptionTypeFlags::kNone}},
{"use_seek_parallel_threshold",
{offsetof(struct HashSpdbRepOptions, use_seek_parallel_threshold),
OptionType::kBoolean, OptionVerificationType::kNormal,
OptionTypeFlags::kNone}},
};

class HashSpdbRepFactory : public MemTableRepFactory {
public:
explicit HashSpdbRepFactory(size_t hash_bucket_count = 1000000) {
options_.hash_bucket_count = hash_bucket_count;
options_.use_seek_parallel_threshold = false;

if (hash_bucket_count == 0) {
options_.use_seek_parallel_threshold = true;
options_.hash_bucket_count = 1000000;
}
RegisterOptions(&options_, &hash_spdb_factory_info);
}

Expand Down Expand Up @@ -597,9 +580,7 @@ class HashSpdbRepFactory : public MemTableRepFactory {
// HashSpdbRepFactory

MemTableRep* HashSpdbRepFactory::PreCreateMemTableRep() {
MemTableRep* hash_spdb =
new HashSpdbRep(nullptr, options_.hash_bucket_count,
options_.use_seek_parallel_threshold);
MemTableRep* hash_spdb = new HashSpdbRep(nullptr, options_.hash_bucket_count);
return hash_spdb;
}

Expand All @@ -613,8 +594,7 @@ void HashSpdbRepFactory::PostCreateMemTableRep(
MemTableRep* HashSpdbRepFactory::CreateMemTableRep(
const MemTableRep::KeyComparator& compare, Allocator* allocator,
const SliceTransform* /*transform*/, Logger* /*logger*/) {
return new HashSpdbRep(compare, allocator, options_.hash_bucket_count,
options_.use_seek_parallel_threshold);
return new HashSpdbRep(compare, allocator, options_.hash_bucket_count);
}

MemTableRepFactory* NewHashSpdbRepFactory(size_t bucket_count) {
Expand Down
4 changes: 1 addition & 3 deletions tools/db_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1863,8 +1863,6 @@ DEFINE_bool(multiread_batched, false, "Use the new MultiGet API");

DEFINE_string(memtablerep, "hash_spdb", "");
DEFINE_int64(hash_bucket_count, 1000000, "hash bucket count");
DEFINE_bool(use_seek_parralel_threshold, true,
"if use seek parralel threshold .");
DEFINE_bool(use_plain_table, false,
"if use plain table instead of block-based table format");
DEFINE_bool(use_cuckoo_table, false, "if use cuckoo table format");
Expand Down Expand Up @@ -1969,7 +1967,7 @@ static Status CreateMemTableRepFactory(
} else if (!strcasecmp(FLAGS_memtablerep.c_str(), "hash_linkedlist")) {
factory->reset(NewHashLinkListRepFactory(FLAGS_hash_bucket_count));
} else if (!strcasecmp(FLAGS_memtablerep.c_str(), "hash_spdb")) {
factory->reset(NewHashSpdbRepFactory(0));
factory->reset(NewHashSpdbRepFactory(FLAGS_hash_bucket_count));
}
return s;
}
Expand Down

0 comments on commit b200e4c

Please sign in to comment.