Created
February 19, 2024 09:43
-
-
Save aclamk/8edbb4e83a3b6a131856e3968eeed166 to your computer and use it in GitHub Desktop.
rocksb hacks to split wal / memtable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/db/db_impl/db_impl.h b/db/db_impl/db_impl.h | |
index 725e77c18..f362eb6b0 100644 | |
--- a/db/db_impl/db_impl.h | |
+++ b/db/db_impl/db_impl.h | |
@@ -232,6 +232,8 @@ class DBImpl : public DB { | |
using DB::Write; | |
virtual Status Write(const WriteOptions& options, | |
WriteBatch* updates) override; | |
+ virtual Status WriteHack(const WriteOptions& options, | |
+ WriteBatch* updates) override; | |
using DB::Get; | |
virtual Status Get(const ReadOptions& options, | |
diff --git a/db/db_impl/db_impl_write.cc b/db/db_impl/db_impl_write.cc | |
index a597c168d..2bd8dbfef 100644 | |
--- a/db/db_impl/db_impl_write.cc | |
+++ b/db/db_impl/db_impl_write.cc | |
@@ -148,6 +148,31 @@ Status DBImpl::Write(const WriteOptions& write_options, WriteBatch* my_batch) { | |
} | |
return s; | |
} | |
+#if 0 | |
+struct HackStruct { | |
+ int canary; | |
+ WriteThread::WriteGroup write_group; | |
+ SequenceNumber current_sequence; | |
+}; | |
+#endif | |
+Status DBImpl::WriteHack(const WriteOptions& write_options, WriteBatch* my_batch) { | |
+ Status s; | |
+ if (write_options.hack_just_memtable) { | |
+ s = WriteBatchInternal::InsertInto( | |
+ my_batch, | |
+ column_family_memtables_.get(), | |
+ &flush_scheduler_, &trim_history_scheduler_, | |
+ write_options.ignore_missing_column_families, | |
+ 0 /*recovery_log_number*/, this, false, | |
+ nullptr, nullptr, | |
+ seq_per_batch_, batch_per_txn_); | |
+ } else { | |
+ s = WriteImpl(write_options, my_batch, | |
+ nullptr, nullptr, 0, false, nullptr, 0, nullptr, nullptr); | |
+ } | |
+ return s; | |
+} | |
+ | |
#ifndef ROCKSDB_LITE | |
Status DBImpl::WriteWithCallback(const WriteOptions& write_options, | |
@@ -549,12 +574,17 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options, | |
if (!parallel) { | |
// w.sequence will be set inside InsertInto | |
- w.status = WriteBatchInternal::InsertInto( | |
+ if (write_options.hack_skip_memtable) { | |
+ //hack_struct->canary = 117; | |
+ w.status = Status::OK(); | |
+ } else { | |
+ w.status = WriteBatchInternal::InsertInto( | |
write_group, current_sequence, column_family_memtables_.get(), | |
&flush_scheduler_, &trim_history_scheduler_, | |
write_options.ignore_missing_column_families, | |
0 /*recovery_log_number*/, this, parallel, seq_per_batch_, | |
batch_per_txn_); | |
+ } | |
} else { | |
write_group.last_sequence = last_sequence; | |
write_thread_.LaunchParallelMemTableWriters(&write_group); | |
diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h | |
index 26c07c19f..82a86bc17 100644 | |
--- a/include/rocksdb/db.h | |
+++ b/include/rocksdb/db.h | |
@@ -508,6 +508,9 @@ class DB { | |
// Returns OK on success, non-OK on failure. | |
// Note: consider setting options.sync = true. | |
virtual Status Write(const WriteOptions& options, WriteBatch* updates) = 0; | |
+ virtual Status WriteHack(const WriteOptions& options, WriteBatch* updates) { | |
+ return Write(options, updates); | |
+ } | |
// If the column family specified by "column_family" contains an entry for | |
// "key", return the corresponding value in "*value". If the entry is a plain | |
diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h | |
index 7a4d8b5a6..17305547a 100644 | |
--- a/include/rocksdb/options.h | |
+++ b/include/rocksdb/options.h | |
@@ -1730,7 +1730,8 @@ struct WriteOptions { | |
// | |
// Default: false | |
bool sync; | |
- | |
+ bool hack_just_memtable; | |
+ bool hack_skip_memtable; | |
// If true, writes will not first go to the write ahead log, | |
// and the write may get lost after a crash. The backup engine | |
// relies on write-ahead logs to back up the memtable, so if | |
@@ -1792,6 +1793,8 @@ struct WriteOptions { | |
WriteOptions() | |
: sync(false), | |
+ hack_just_memtable(false), | |
+ hack_skip_memtable(false), | |
disableWAL(false), | |
ignore_missing_column_families(false), | |
no_slowdown(false), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment