Skip to content

Commit

Permalink
CodecRocksDB: disable WAL
Browse files Browse the repository at this point in the history
  • Loading branch information
benini committed Jan 8, 2022
1 parent ba73ad0 commit 77f5144
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
26 changes: 13 additions & 13 deletions bench_results.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Benchmark using the first 3 million games of 2021-11 lichess database (https://database.lichess.org/standard/lichess_db_standard_rated_2021-11.pgn.bz2)

1) ROCKSDB (4GB - 7z 579MB)
Load (314 ms) 3000000 games: C:\Users\user\Downloads\test (SCID4)
Imported (38782 ms) 3000000 games: C:\Users\user\Downloads\test_rocks (ROCKSDB)
Open (1301 ms) 3000000 games: C:\Users\user\Downloads\test_rocks (ROCKSDB)
Search pos (1526 ms): 69718 games - r1bqkbnr/pp1ppppp/2n5/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq
Search pos (127 ms): 0 games - r4rk1/p2n1ppp/1p3n2/2p5/2PP4/4BN2/P4PPP/R3R1K1 w
Search pos (71 ms): 0 games - 5k2/2R2p1p/3p2p1/p7/8/r5P1/4KP1P/8 w
Search pos (1029 ms): 204 games - r2qkb1r/pp2pppp/2bp1n2/6B1/3QP3/2N2N2/PPP2PPP/R3K2R b KQkq
Search pos (37 ms): 0 games - k6r/1pQ2pp1/pBq1p2p/8/3R1P1P/bPK5/2P5/8 w
Search pos (228 ms): 32767 games - r1bqkbnr/pp1ppppp/2n5/2p5/3PP3/5N2/PPP2PPP/RNBQKB1R b KQkq
Search pos (35 ms): 0 games - r2nr1k1/pp2B2p/q3bQp1/4p1N1/4P3/7P/2P3P1/1R3RK1 w
Search pos (156 ms): 801 games - rnbqk1nr/ppp1ppbp/3p2p1/8/3PPP2/2N5/PPP3PP/R1BQKBNR b KQkq
Collect tags (8287 ms): C:\Users\user\Downloads\test_rocks (ROCKSDB)
Load (334 ms) 3000000 games: C:\Users\user\Downloads\test (SCID4)
Imported (19101 ms) 3000000 games: C:\Users\user\Downloads\test_rocks (ROCKSDB)
Open (1338 ms) 3000000 games: C:\Users\user\Downloads\test_rocks (ROCKSDB)
Search pos (1587 ms): 69718 games - r1bqkbnr/pp1ppppp/2n5/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq
Search pos (130 ms): 0 games - r4rk1/p2n1ppp/1p3n2/2p5/2PP4/4BN2/P4PPP/R3R1K1 w
Search pos (70 ms): 0 games - 5k2/2R2p1p/3p2p1/p7/8/r5P1/4KP1P/8 w
Search pos (1068 ms): 204 games - r2qkb1r/pp2pppp/2bp1n2/6B1/3QP3/2N2N2/PPP2PPP/R3K2R b KQkq
Search pos (40 ms): 0 games - k6r/1pQ2pp1/pBq1p2p/8/3R1P1P/bPK5/2P5/8 w
Search pos (248 ms): 32767 games - r1bqkbnr/pp1ppppp/2n5/2p5/3PP3/5N2/PPP2PPP/RNBQKB1R b KQkq
Search pos (37 ms): 0 games - r2nr1k1/pp2B2p/q3bQp1/4p1N1/4P3/7P/2P3P1/1R3RK1 w
Search pos (189 ms): 801 games - rnbqk1nr/ppp1ppbp/3p2p1/8/3PPP2/2N5/PPP3PP/R1BQKBNR b KQkq
Collect tags (10307 ms): C:\Users\user\Downloads\test_rocks (ROCKSDB)
BlackRatingDiff 2991447 BlackTitle 17051 Opening 3000000 Termination 3000000 TimeControl 3000000 UTCDate 3000000 UTCTime 3000000 WhiteRatingDiff 2991447 WhiteTitle 16750
Search pgn (94004 ms): 3000000 games - White
Search pgn (93213 ms): 3000000 games - White


2) ROCKSB sorted by storedline (4GB - 7z 565MB)
Expand Down
11 changes: 7 additions & 4 deletions src/codec_rocksdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CodecRocksDB : public ICodecDatabase {
rocksdb::DB* db_ = nullptr;
std::vector<rocksdb::ColumnFamilyHandle*> handles;
rocksdb::PinnableSlice slice_;
rocksdb::WriteOptions writeopt_;

enum : uint64_t {
LIMIT_NUMGAMES = (1ULL << 32) - 2,
Expand Down Expand Up @@ -77,7 +78,7 @@ class CodecRocksDB : public ICodecDatabase {
}

errorT setExtraInfo(const char* tagname, const char* new_value) override {
if (!db_->Put({}, handles[0], tagname, new_value).ok())
if (!db_->Put(writeopt_, handles[0], tagname, new_value).ok())
return ERROR_FileWrite;

return OK;
Expand Down Expand Up @@ -148,6 +149,7 @@ class CodecRocksDB : public ICodecDatabase {

idx_ = idx;
nb_ = nb;
writeopt_.disableWAL = true;

if (fMode == FMODE_Create)
return create_db(dbname);
Expand Down Expand Up @@ -266,7 +268,7 @@ class CodecRocksDB : public ICodecDatabase {
char value[5];
value[0] = nt;
encode_uint32(value + 1, res.second);
if (!db_->Put({}, handles[1], {value, 5}, name).ok())
if (!db_->Put(writeopt_, handles[1], {value, 5}, name).ok())
res.first = ERROR_FileWrite;

return res;
Expand All @@ -283,7 +285,8 @@ class CodecRocksDB : public ICodecDatabase {
char key[4];
encode_uint32(key, replaced);
auto moves = reinterpret_cast<const char*>(data.data());
return db_->Put({}, handles[2], {key, 4}, {moves, data.size()}).ok()
return db_->Put(writeopt_, handles[2], {key, 4}, {moves, data.size()})
.ok()
? OK
: ERROR_FileWrite;
}
Expand All @@ -305,7 +308,7 @@ class CodecRocksDB : public ICodecDatabase {
char key[5];
key[0] = 5;
encode_uint32(key + 1, gnum);
return db_->Put({}, handles[1], {key, 5}, {buf, 46}).ok()
return db_->Put(writeopt_, handles[1], {key, 5}, {buf, 46}).ok()
? OK
: ERROR_FileWrite;
}
Expand Down

0 comments on commit 77f5144

Please sign in to comment.