mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 11:43:49 +00:00
14b3f683a1
Summary: WriteUnPrepared adds a virtual function, MaxUnpreparedSequenceNumber, to ReadCallback, which returns 0 unless WriteUnPrepared is enabled and the transaction has uncommitted data written to the DB. Together with snapshot sequence number, this determines the last sequence that is visible to reads. The patch clarifies the guarantees of the GetIterator API in WriteUnPrepared transactions and make use of that to statically initialize the read callback and thus avoid the virtual call. Furthermore it increases the minimum value for min_uncommitted from 0 to 1 as seq 0 is used only for last level keys that are committed in all snapshots. The following benchmark shows +0.26% higher throughput in seekrandom benchmark. Benchmark: ./db_bench --benchmarks=fillrandom --use_existing_db=0 --num=1000000 --db=/dev/shm/dbbench ./db_bench --benchmarks=seekrandom[X10] --use_existing_db=1 --db=/dev/shm/dbbench --num=1000000 --duration=60 --seek_nexts=100 seekrandom [AVG 10 runs] : 20355 ops/sec; 225.2 MB/sec seekrandom [MEDIAN 10 runs] : 20425 ops/sec; 225.9 MB/sec ./db_bench_lessvirtual3 --benchmarks=seekrandom[X10] --use_existing_db=1 --db=/dev/shm/dbbench --num=1000000 --duration=60 --seek_nexts=100 seekrandom [AVG 10 runs] : 20409 ops/sec; 225.8 MB/sec seekrandom [MEDIAN 10 runs] : 20487 ops/sec; 226.6 MB/sec Pull Request resolved: https://github.com/facebook/rocksdb/pull/5049 Differential Revision: D14366459 Pulled By: maysamyabandeh fbshipit-source-id: ebaff8908332a5ae9af7defeadabcb624be660ef
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#include "db/snapshot_checker.h"
|
|
|
|
#ifdef ROCKSDB_LITE
|
|
#include <assert.h>
|
|
#endif // ROCKSDB_LITE
|
|
|
|
#include "utilities/transactions/write_prepared_txn_db.h"
|
|
|
|
namespace rocksdb {
|
|
|
|
#ifdef ROCKSDB_LITE
|
|
WritePreparedSnapshotChecker::WritePreparedSnapshotChecker(
|
|
WritePreparedTxnDB* /*txn_db*/) {}
|
|
|
|
SnapshotCheckerResult WritePreparedSnapshotChecker::CheckInSnapshot(
|
|
SequenceNumber /*sequence*/, SequenceNumber /*snapshot_sequence*/) const {
|
|
// Should never be called in LITE mode.
|
|
assert(false);
|
|
return SnapshotCheckerResult::kInSnapshot;
|
|
}
|
|
|
|
#else
|
|
|
|
WritePreparedSnapshotChecker::WritePreparedSnapshotChecker(
|
|
WritePreparedTxnDB* txn_db)
|
|
: txn_db_(txn_db){};
|
|
|
|
SnapshotCheckerResult WritePreparedSnapshotChecker::CheckInSnapshot(
|
|
SequenceNumber sequence, SequenceNumber snapshot_sequence) const {
|
|
bool snapshot_released = false;
|
|
// TODO(myabandeh): set min_uncommitted
|
|
bool in_snapshot = txn_db_->IsInSnapshot(
|
|
sequence, snapshot_sequence, kMinUnCommittedSeq, &snapshot_released);
|
|
if (snapshot_released) {
|
|
return SnapshotCheckerResult::kSnapshotReleased;
|
|
}
|
|
return in_snapshot ? SnapshotCheckerResult::kInSnapshot
|
|
: SnapshotCheckerResult::kNotInSnapshot;
|
|
}
|
|
|
|
#endif // ROCKSDB_LITE
|
|
DisableGCSnapshotChecker DisableGCSnapshotChecker::instance_;
|
|
|
|
} // namespace rocksdb
|