Skip to content

Instantly share code, notes, and snippets.

View ajkr's full-sized avatar

Andrew Kryczka ajkr

  • Facebook
  • Bay Area
View GitHub Profile
#include <assert.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void* run_allocs(void* arg) {
uint64_t kSmallAllocSize = 32 << 10, kLargeAllocSize = 16 << 20;
#include <assert.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void* run_allocs(void* arg) {
uint64_t kSmallAllocSize = 32 << 10, kLargeAllocSize = 16 << 20;
// First, create a DB using 6.14 with #7612 applied.
$ rm -rf ./tmp-db && ./ldb put a b --db=./tmp-db --create_if_missing
OK
// Second, update to version number to 6.15 and stop serializing the option.
$ git diff
diff --git a/include/rocksdb/version.h b/include/rocksdb/version.h
index bf963d917..f9055d651 100644
--- a/include/rocksdb/version.h
+++ b/include/rocksdb/version.h
@ajkr
ajkr / tmp.c
Created September 18, 2020 01:00
#include <fcntl.h>
#include <linux/fs.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main(int argc, char** argv) {
diff --git a/db/db_compaction_test.cc b/db/db_compaction_test.cc
index 48a080446..a4dcb538f 100644
--- a/db/db_compaction_test.cc
+++ b/db/db_compaction_test.cc
@@ -3646,9 +3646,20 @@ TEST_F(DBCompactionTest, NoCompactBottomLevelFilesWithDeletions) {
// just need to bump seqnum so ReleaseSnapshot knows the newest key in the SST
// files does not need to be preserved in case of a future snapshot.
ASSERT_OK(Put(Key(0), "val"));
- // release snapshot and no compaction should be triggered.
- db_->ReleaseSnapshot(snapshot);
diff --git a/db/external_sst_file_test.cc b/db/external_sst_file_test.cc
index ebd6cb2b1..5e5c0527c 100644
--- a/db/external_sst_file_test.cc
+++ b/db/external_sst_file_test.cc
@@ -2335,6 +2335,34 @@ TEST_F(ExternalSSTFileTest, SkipBloomFilter) {
}
}
+TEST_F(ExternalSSTFileTest, IngestMultipleFilesToL0) {
+ const int kNumLevels = 2;
$ git diff
diff --git a/db/external_sst_file_test.cc b/db/external_sst_file_test.cc
index ebd6cb2b1..5e5c0527c 100644
--- a/db/external_sst_file_test.cc
+++ b/db/external_sst_file_test.cc
@@ -2335,6 +2335,34 @@ TEST_F(ExternalSSTFileTest, SkipBloomFilter) {
}
}
+TEST_F(ExternalSSTFileTest, IngestMultipleFilesToL0) {
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
int main(int argc, char** argv) {
if (argc != 3) {
fprintf(stderr, "usage: %s <num blocks> <block size>\n", argv[0]);
exit(1);
}
int num_blocks = atoi(argv[1]);
commands to build/run:
$ capnp compile -oc++ ./kv.capnp
$ g++ -std=c++14 ./kv.capnp.c++ ./kv-server.c++ -o ./kv-server -lkj -lkj-async -lcapnp-rpc -lcapnp -lrocksdb -lpthread -lsnappy -lz -ldl
$ g++ -std=c++14 ./kv.capnp.c++ ./kv-client.c++ -o ./kv-client -lkj -lkj-async -lcapnp-rpc -lcapnp
$ strace -fe writev ./kv-server localhost:12345 ./tmp-db/
$ ./kv-client localhost:12345 a b
$ echo "x ==> y" | ./ldb write_extern_sst --db=./tmp ./tmp.sst
external SST file written to ./tmp.sst
$ strace -ye openat,fsync ./ldb ingest_extern_sst --create_if_missing --db=./tmp ./tmp.sst |& grep -E 'fsync|O_CREAT.*sst'
fsync(4</home/andrew/rocksdb/tmp>) = 0
fsync(16</home/andrew/rocksdb/tmp/OPTIONS-000122.dbtmp>) = 0
openat(AT_FDCWD, "./tmp/000124.sst", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644) = 17</home/andrew/rocksdb/tmp/000124.sst>