@nxtedition/rocksdb 10.0.19 → 10.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tap/test-results/node_modules/abstract-level/test/get-test.js.tap +0 -0
- package/.tap/test-results/test/abstract-level-test.js.tap +1077 -0
- package/.tap/test-results/test/batch-test.js.tap +12 -0
- package/.tap/test-results/test/chained-batch-gc-test.js.tap +11 -0
- package/.tap/test-results/test/cleanup-hanging-iterators-test.js.tap +135 -0
- package/.tap/test-results/test/clear-gc-test.js.tap +13 -0
- package/.tap/test-results/test/column-test.js.tap +55 -0
- package/.tap/test-results/test/common.js.tap +0 -0
- package/.tap/test-results/test/compression-test.js.tap +30 -0
- package/.tap/test-results/test/db-identity.js.tap +12 -0
- package/.tap/test-results/test/electron.js.tap +0 -0
- package/.tap/test-results/test/env-cleanup-hook-test.js.tap +40 -0
- package/.tap/test-results/test/env-cleanup-hook.js.tap +0 -0
- package/.tap/test-results/test/gc.js.tap +0 -0
- package/.tap/test-results/test/getproperty-test.js.tap +29 -0
- package/.tap/test-results/test/iterator-gc-test.js.tap +15 -0
- package/.tap/test-results/test/iterator-hwm-test.js.tap +131 -0
- package/.tap/test-results/test/iterator-recursion-test.js.tap +12 -0
- package/.tap/test-results/test/iterator-starvation-test.js.tap +73 -0
- package/.tap/test-results/test/iterator-test.js.tap +6 -0
- package/.tap/test-results/test/leak-tester-batch.js.tap +0 -0
- package/.tap/test-results/test/leak-tester-iterator.js.tap +0 -0
- package/.tap/test-results/test/leak-tester.js.tap +0 -0
- package/.tap/test-results/test/lock-test.js.tap +18 -0
- package/.tap/test-results/test/lock.js.tap +0 -0
- package/.tap/test-results/test/make.js.tap +0 -0
- package/.tap/test-results/test/max-rev-merge.js.tap +0 -0
- package/.tap/test-results/test/merge-operator-test.js.tap +12 -0
- package/.tap/test-results/test/mkdir-test.js.tap +15 -0
- package/.tap/test-results/test/segfault-test.js.tap +76 -0
- package/.tap/test-results/test/stack-blower.js.tap +0 -0
- package/benchmarks/rocks-vs-map.mjs +68 -0
- package/binding.cc +111 -67
- package/deps/rocksdb/rocksdb/README.md +29 -0
- package/deps/rocksdb/rocksdb/microbench/README.md +60 -0
- package/deps/rocksdb/rocksdb/plugin/README.md +43 -0
- package/deps/rocksdb/rocksdb/port/README +10 -0
- package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/README +13 -0
- package/index.js +4 -0
- package/package.json +3 -1
- package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
- package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
- package/tmp/000099.sst +0 -0
- package/tmp/000102.sst +0 -0
- package/tmp/000103.log +0 -0
- package/tmp/CURRENT +1 -0
- package/tmp/IDENTITY +1 -0
- package/tmp/LOCK +0 -0
- package/tmp/MANIFEST-000104 +0 -0
- package/tmp/OPTIONS-000098 +207 -0
- package/tmp/OPTIONS-000106 +207 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
TAP version 13
|
|
2
|
+
# close() waits for pending get()
|
|
3
|
+
ok 1 no error from open()
|
|
4
|
+
ok 2 no error from put()
|
|
5
|
+
ok 3 no error from operation
|
|
6
|
+
ok 4 no error from close()
|
|
7
|
+
ok 5 operation(s) finished before close
|
|
8
|
+
# close() waits for pending put()
|
|
9
|
+
ok 6 no error from open()
|
|
10
|
+
ok 7 no error from put()
|
|
11
|
+
ok 8 no error from operation
|
|
12
|
+
ok 9 no error from close()
|
|
13
|
+
ok 10 operation(s) finished before close
|
|
14
|
+
# close() waits for pending put() with { sync }
|
|
15
|
+
ok 11 no error from open()
|
|
16
|
+
ok 12 no error from put()
|
|
17
|
+
ok 13 no error from operation
|
|
18
|
+
ok 14 no error from close()
|
|
19
|
+
ok 15 operation(s) finished before close
|
|
20
|
+
# close() waits for pending del()
|
|
21
|
+
ok 16 no error from open()
|
|
22
|
+
ok 17 no error from put()
|
|
23
|
+
ok 18 no error from operation
|
|
24
|
+
ok 19 no error from close()
|
|
25
|
+
ok 20 operation(s) finished before close
|
|
26
|
+
# close() waits for pending del() with { sync }
|
|
27
|
+
ok 21 no error from open()
|
|
28
|
+
ok 22 no error from put()
|
|
29
|
+
ok 23 no error from operation
|
|
30
|
+
ok 24 no error from close()
|
|
31
|
+
ok 25 operation(s) finished before close
|
|
32
|
+
# close() waits for pending batch([])
|
|
33
|
+
ok 26 no error from open()
|
|
34
|
+
ok 27 no error from put()
|
|
35
|
+
ok 28 no error from operation
|
|
36
|
+
ok 29 no error from close()
|
|
37
|
+
ok 30 operation(s) finished before close
|
|
38
|
+
# close() waits for pending batch([]) with { sync }
|
|
39
|
+
ok 31 no error from open()
|
|
40
|
+
ok 32 no error from put()
|
|
41
|
+
ok 33 no error from operation
|
|
42
|
+
ok 34 no error from close()
|
|
43
|
+
ok 35 operation(s) finished before close
|
|
44
|
+
# close() waits for pending batch()
|
|
45
|
+
ok 36 no error from open()
|
|
46
|
+
ok 37 no error from put()
|
|
47
|
+
ok 38 no error from operation
|
|
48
|
+
ok 39 no error from close()
|
|
49
|
+
ok 40 operation(s) finished before close
|
|
50
|
+
# close() waits for pending batch() with { sync }
|
|
51
|
+
ok 41 no error from open()
|
|
52
|
+
ok 42 no error from put()
|
|
53
|
+
ok 43 no error from operation
|
|
54
|
+
ok 44 no error from close()
|
|
55
|
+
ok 45 operation(s) finished before close
|
|
56
|
+
# close() waits for pending operations
|
|
57
|
+
ok 46 no error from open()
|
|
58
|
+
ok 47 no error from put()
|
|
59
|
+
ok 48 no error from operation
|
|
60
|
+
ok 49 no error from operation
|
|
61
|
+
ok 50 no error from operation
|
|
62
|
+
ok 51 no error from operation
|
|
63
|
+
ok 52 no error from operation
|
|
64
|
+
ok 53 no error from operation
|
|
65
|
+
ok 54 no error from operation
|
|
66
|
+
ok 55 no error from operation
|
|
67
|
+
ok 56 no error from operation
|
|
68
|
+
ok 57 no error from close()
|
|
69
|
+
ok 58 operation(s) finished before close
|
|
70
|
+
|
|
71
|
+
1..58
|
|
72
|
+
# tests 58
|
|
73
|
+
# pass 58
|
|
74
|
+
|
|
75
|
+
# ok
|
|
76
|
+
|
|
File without changes
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { bench, run } from 'mitata'
|
|
2
|
+
import { RocksLevel } from '../index.js'
|
|
3
|
+
import { LRUCache } from 'lru-cache'
|
|
4
|
+
|
|
5
|
+
const values = []
|
|
6
|
+
for (let x = 0; x < 1e3; x++) {
|
|
7
|
+
values.push(Buffer.from(Math.random().toString(36).repeat(4)))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const db = new RocksLevel('./tmp', {
|
|
11
|
+
keyEncoding: 'buffer',
|
|
12
|
+
valueEncoding: 'buffer',
|
|
13
|
+
parallelism: 4,
|
|
14
|
+
pipelinedWrite: false,
|
|
15
|
+
// unorderedWrite: true,
|
|
16
|
+
columns: {
|
|
17
|
+
default: {
|
|
18
|
+
cacheSize: 128e6,
|
|
19
|
+
memtableMemoryBudget: 128e6,
|
|
20
|
+
compaction: 'level'
|
|
21
|
+
// optimize: 'point-lookup',
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
await db.open()
|
|
26
|
+
|
|
27
|
+
const map = new Map()
|
|
28
|
+
const lru = new LRUCache({ max: 10e3 })
|
|
29
|
+
|
|
30
|
+
for (const value of values) {
|
|
31
|
+
await db.put(value, value)
|
|
32
|
+
map.set(value.toString(), value.toString())
|
|
33
|
+
lru.set(value.toString(), value)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let x = 0
|
|
37
|
+
|
|
38
|
+
const getOpts = {
|
|
39
|
+
keyEncoding: 'buffer',
|
|
40
|
+
valueEncoding: 'buffer',
|
|
41
|
+
fillCache: true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
x = db._getMany(values, getOpts).length
|
|
45
|
+
|
|
46
|
+
bench('rocks async', async () => {
|
|
47
|
+
x += (await db._getMany(values, getOpts)).length
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
bench('rocks sync', async () => {
|
|
51
|
+
x += db._getManySync(values, getOpts).length
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
bench('map', () => {
|
|
55
|
+
for (const value of values) {
|
|
56
|
+
x += map.get(value.toString()).length
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
bench('lru', () => {
|
|
61
|
+
for (const value of values) {
|
|
62
|
+
x += lru.get(value.toString()).length
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
await run()
|
|
67
|
+
|
|
68
|
+
console.log(x)
|
package/binding.cc
CHANGED
|
@@ -666,7 +666,6 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
|
|
|
666
666
|
|
|
667
667
|
if (cacheSize) {
|
|
668
668
|
tableOptions.block_cache = rocksdb::HyperClockCacheOptions(cacheSize, 0).MakeSharedCache();
|
|
669
|
-
tableOptions.cache_index_and_filter_blocks = true;
|
|
670
669
|
NAPI_STATUS_RETURN(
|
|
671
670
|
GetProperty(env, options, "cacheIndexAndFilterBlocks", tableOptions.cache_index_and_filter_blocks));
|
|
672
671
|
} else {
|
|
@@ -828,7 +827,6 @@ NAPI_METHOD(db_open) {
|
|
|
828
827
|
|
|
829
828
|
dbOptions.avoid_unnecessary_blocking_io = true;
|
|
830
829
|
dbOptions.write_dbid_to_manifest = true;
|
|
831
|
-
dbOptions.enable_pipelined_write = true; // We only write in the main thread...
|
|
832
830
|
dbOptions.create_missing_column_families = true;
|
|
833
831
|
dbOptions.fail_if_options_file_error = true;
|
|
834
832
|
|
|
@@ -960,26 +958,76 @@ NAPI_METHOD(db_close) {
|
|
|
960
958
|
return 0;
|
|
961
959
|
}
|
|
962
960
|
|
|
963
|
-
NAPI_METHOD(
|
|
961
|
+
NAPI_METHOD(db_get_many_sync) {
|
|
964
962
|
NAPI_ARGV(4);
|
|
965
963
|
|
|
966
964
|
Database* database;
|
|
967
965
|
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
|
|
968
966
|
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
967
|
+
uint32_t size;
|
|
968
|
+
NAPI_STATUS_THROWS(napi_get_array_length(env, argv[1], &size));
|
|
969
|
+
|
|
970
|
+
const auto options = argv[2];
|
|
971
|
+
|
|
972
|
+
bool fillCache = true;
|
|
973
|
+
NAPI_STATUS_THROWS(GetProperty(env, options, "fillCache", fillCache));
|
|
974
|
+
|
|
975
|
+
bool ignoreRangeDeletions = false;
|
|
976
|
+
NAPI_STATUS_THROWS(GetProperty(env, options, "ignoreRangeDeletions", ignoreRangeDeletions));
|
|
977
|
+
|
|
978
|
+
rocksdb::ColumnFamilyHandle* column = database->db->DefaultColumnFamily();
|
|
979
|
+
NAPI_STATUS_THROWS(GetProperty(env, options, "column", column));
|
|
980
|
+
|
|
981
|
+
auto callback = argv[3];
|
|
982
|
+
|
|
983
|
+
std::vector<rocksdb::Slice> keys{size};
|
|
984
|
+
std::vector<rocksdb::Status> statuses{size};
|
|
985
|
+
std::vector<rocksdb::PinnableSlice> values{size};
|
|
986
|
+
|
|
987
|
+
for (uint32_t n = 0; n < size; n++) {
|
|
988
|
+
napi_value element;
|
|
989
|
+
char* buf;
|
|
990
|
+
size_t length;
|
|
991
|
+
NAPI_STATUS_THROWS(napi_get_element(env, argv[1], n, &element));
|
|
992
|
+
NAPI_STATUS_THROWS(napi_get_buffer_info(env, element, reinterpret_cast<void**>(&buf), &length));
|
|
993
|
+
keys[n] = rocksdb::Slice{ buf, length };
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
rocksdb::ReadOptions readOptions;
|
|
997
|
+
readOptions.fill_cache = fillCache;
|
|
998
|
+
readOptions.ignore_range_deletions = ignoreRangeDeletions;
|
|
999
|
+
|
|
1000
|
+
database->db->MultiGet(readOptions, column, size, keys.data(), values.data(), statuses.data());
|
|
1001
|
+
|
|
1002
|
+
napi_value ret;
|
|
1003
|
+
NAPI_STATUS_THROWS(napi_create_array_with_length(env, size, &ret));
|
|
1004
|
+
|
|
1005
|
+
for (uint32_t idx = 0; idx < size; idx++) {
|
|
1006
|
+
const auto& status = statuses[idx];
|
|
1007
|
+
const auto& value = values[idx];
|
|
1008
|
+
|
|
1009
|
+
napi_value element;
|
|
1010
|
+
if (status.IsNotFound()) {
|
|
1011
|
+
NAPI_STATUS_THROWS(napi_get_undefined(env, &element));
|
|
1012
|
+
} else {
|
|
1013
|
+
ROCKS_STATUS_THROWS_NAPI(status);
|
|
1014
|
+
NAPI_STATUS_THROWS(napi_create_buffer_copy(env, value.size(), value.data(), nullptr, &element));
|
|
980
1015
|
}
|
|
1016
|
+
NAPI_STATUS_THROWS(napi_set_element(env, argv[1], idx, element));
|
|
981
1017
|
}
|
|
982
1018
|
|
|
1019
|
+
return ret;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
NAPI_METHOD(db_get_many) {
|
|
1023
|
+
NAPI_ARGV(4);
|
|
1024
|
+
|
|
1025
|
+
Database* database;
|
|
1026
|
+
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
|
|
1027
|
+
|
|
1028
|
+
uint32_t size;
|
|
1029
|
+
NAPI_STATUS_THROWS(napi_get_array_length(env, argv[1], &size));
|
|
1030
|
+
|
|
983
1031
|
const auto options = argv[2];
|
|
984
1032
|
|
|
985
1033
|
bool fillCache = true;
|
|
@@ -996,9 +1044,26 @@ NAPI_METHOD(db_get_many) {
|
|
|
996
1044
|
auto snapshot = std::shared_ptr<const rocksdb::Snapshot>(
|
|
997
1045
|
database->db->GetSnapshot(), [database](auto ptr) { database->db->ReleaseSnapshot(ptr); });
|
|
998
1046
|
|
|
999
|
-
|
|
1047
|
+
// TODO (fix): Ensure lifetime of buffer?
|
|
1048
|
+
std::vector<rocksdb::Slice> keys { size };
|
|
1049
|
+
|
|
1050
|
+
for (uint32_t n = 0; n < size; n++) {
|
|
1051
|
+
napi_value element;
|
|
1052
|
+
char* buf;
|
|
1053
|
+
size_t length;
|
|
1054
|
+
NAPI_STATUS_THROWS(napi_get_element(env, argv[1], n, &element));
|
|
1055
|
+
NAPI_STATUS_THROWS(napi_get_buffer_info(env, element, reinterpret_cast<void**>(&buf), &length));
|
|
1056
|
+
keys[n] = rocksdb::Slice{ buf, length };
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
struct State {
|
|
1060
|
+
std::vector<rocksdb::Status> statuses;
|
|
1061
|
+
std::vector<rocksdb::PinnableSlice> values;
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
runAsync<State>(
|
|
1000
1065
|
"leveldown.get.many", env, callback,
|
|
1001
|
-
[=, keys = std::move(keys), snapshot = std::move(snapshot)](auto&
|
|
1066
|
+
[=, keys = std::move(keys), snapshot = std::move(snapshot)](auto& state) {
|
|
1002
1067
|
rocksdb::ReadOptions readOptions;
|
|
1003
1068
|
readOptions.fill_cache = fillCache;
|
|
1004
1069
|
readOptions.snapshot = snapshot.get();
|
|
@@ -1006,39 +1071,30 @@ NAPI_METHOD(db_get_many) {
|
|
|
1006
1071
|
readOptions.ignore_range_deletions = ignoreRangeDeletions;
|
|
1007
1072
|
readOptions.optimize_multiget_for_io = true;
|
|
1008
1073
|
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
std::vector<rocksdb::Status> statuses;
|
|
1074
|
+
state.statuses.resize(size);
|
|
1075
|
+
state.values.resize(size);
|
|
1012
1076
|
|
|
1013
|
-
statuses.
|
|
1014
|
-
values.resize(size);
|
|
1015
|
-
|
|
1016
|
-
database->db->MultiGet(readOptions, column, size, keys.data(), values.data(), statuses.data());
|
|
1017
|
-
|
|
1018
|
-
for (size_t idx = 0; idx < size; idx++) {
|
|
1019
|
-
if (statuses[idx].IsNotFound()) {
|
|
1020
|
-
values[idx] = rocksdb::PinnableSlice(nullptr);
|
|
1021
|
-
} else if (!statuses[idx].ok()) {
|
|
1022
|
-
return statuses[idx];
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1077
|
+
database->db->MultiGet(readOptions, column, size, keys.data(), state.values.data(), state.statuses.data());
|
|
1025
1078
|
|
|
1026
1079
|
return rocksdb::Status::OK();
|
|
1027
1080
|
},
|
|
1028
|
-
[=](auto&
|
|
1081
|
+
[=](auto& state, auto env, auto& argv) {
|
|
1029
1082
|
argv.resize(2);
|
|
1030
1083
|
|
|
1031
|
-
NAPI_STATUS_RETURN(napi_create_array_with_length(env,
|
|
1084
|
+
NAPI_STATUS_RETURN(napi_create_array_with_length(env, size, &argv[1]));
|
|
1085
|
+
|
|
1086
|
+
for (uint32_t idx = 0; idx < size; idx++) {
|
|
1087
|
+
const auto& status = state.statuses[idx];
|
|
1088
|
+
const auto& value = state.values[idx];
|
|
1032
1089
|
|
|
1033
|
-
for (size_t idx = 0; idx < values.size(); idx++) {
|
|
1034
1090
|
napi_value element;
|
|
1035
|
-
if (
|
|
1036
|
-
auto ptr = new rocksdb::PinnableSlice(std::move(values[idx]));
|
|
1037
|
-
NAPI_STATUS_RETURN(napi_create_external_buffer(env, ptr->size(), const_cast<char*>(ptr->data()), Finalize<rocksdb::PinnableSlice>, ptr, &element));
|
|
1038
|
-
} else {
|
|
1091
|
+
if (status.IsNotFound()) {
|
|
1039
1092
|
NAPI_STATUS_RETURN(napi_get_undefined(env, &element));
|
|
1093
|
+
} else {
|
|
1094
|
+
ROCKS_STATUS_RETURN_NAPI(status);
|
|
1095
|
+
NAPI_STATUS_RETURN(napi_create_buffer_copy(env, value.size(), value.data(), nullptr, &element));
|
|
1040
1096
|
}
|
|
1041
|
-
NAPI_STATUS_RETURN(napi_set_element(env, argv[1],
|
|
1097
|
+
NAPI_STATUS_RETURN(napi_set_element(env, argv[1], idx, element));
|
|
1042
1098
|
}
|
|
1043
1099
|
|
|
1044
1100
|
return napi_ok;
|
|
@@ -1560,35 +1616,22 @@ NAPI_METHOD(batch_write) {
|
|
|
1560
1616
|
bool lowPriority = false;
|
|
1561
1617
|
NAPI_STATUS_THROWS(GetProperty(env, options, "lowPriority", lowPriority));
|
|
1562
1618
|
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
writeOptions.no_slowdown = true;
|
|
1567
|
-
|
|
1568
|
-
const auto status = database->db->Write(writeOptions, batch);
|
|
1569
|
-
|
|
1570
|
-
if (status == rocksdb::Status::Incomplete()) {
|
|
1571
|
-
napi_ref batchRef;
|
|
1572
|
-
NAPI_STATUS_THROWS(napi_create_reference(env, argv[1], 1, &batchRef));
|
|
1573
|
-
|
|
1574
|
-
runAsync<int64_t>(
|
|
1575
|
-
"leveldown.batch.write", env, callback,
|
|
1576
|
-
[=](int64_t& seq) {
|
|
1577
|
-
rocksdb::WriteOptions writeOptions;
|
|
1578
|
-
writeOptions.sync = sync;
|
|
1579
|
-
writeOptions.low_pri = lowPriority;
|
|
1580
|
-
return database->db->Write(writeOptions, batch);
|
|
1581
|
-
},
|
|
1582
|
-
[=](int64_t& seq, auto env, auto& argv) {
|
|
1583
|
-
NAPI_STATUS_RETURN(napi_delete_reference(env, batchRef));
|
|
1584
|
-
return napi_ok;
|
|
1585
|
-
});
|
|
1619
|
+
// TODO (fix): This ref can leak on error...
|
|
1620
|
+
napi_ref batchRef;
|
|
1621
|
+
NAPI_STATUS_THROWS(napi_create_reference(env, argv[1], 1, &batchRef));
|
|
1586
1622
|
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1623
|
+
runAsync<int64_t>(
|
|
1624
|
+
"leveldown.batch.write", env, callback,
|
|
1625
|
+
[=](int64_t& seq) {
|
|
1626
|
+
rocksdb::WriteOptions writeOptions;
|
|
1627
|
+
writeOptions.sync = sync;
|
|
1628
|
+
writeOptions.low_pri = lowPriority;
|
|
1629
|
+
return database->db->Write(writeOptions, batch);
|
|
1630
|
+
},
|
|
1631
|
+
[=](int64_t& seq, auto env, auto& argv) {
|
|
1632
|
+
NAPI_STATUS_RETURN(napi_delete_reference(env, batchRef));
|
|
1633
|
+
return napi_ok;
|
|
1634
|
+
});
|
|
1592
1635
|
|
|
1593
1636
|
return result;
|
|
1594
1637
|
}
|
|
@@ -1650,6 +1693,7 @@ NAPI_INIT() {
|
|
|
1650
1693
|
NAPI_EXPORT_FUNCTION(db_get_location);
|
|
1651
1694
|
NAPI_EXPORT_FUNCTION(db_close);
|
|
1652
1695
|
NAPI_EXPORT_FUNCTION(db_get_many);
|
|
1696
|
+
NAPI_EXPORT_FUNCTION(db_get_many_sync);
|
|
1653
1697
|
NAPI_EXPORT_FUNCTION(db_clear);
|
|
1654
1698
|
NAPI_EXPORT_FUNCTION(db_get_property);
|
|
1655
1699
|
NAPI_EXPORT_FUNCTION(db_get_latest_sequence);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
## RocksDB: A Persistent Key-Value Store for Flash and RAM Storage
|
|
2
|
+
|
|
3
|
+
[](https://circleci.com/gh/facebook/rocksdb)
|
|
4
|
+
|
|
5
|
+
RocksDB is developed and maintained by Facebook Database Engineering Team.
|
|
6
|
+
It is built on earlier work on [LevelDB](https://github.com/google/leveldb) by Sanjay Ghemawat (sanjay@google.com)
|
|
7
|
+
and Jeff Dean (jeff@google.com)
|
|
8
|
+
|
|
9
|
+
This code is a library that forms the core building block for a fast
|
|
10
|
+
key-value server, especially suited for storing data on flash drives.
|
|
11
|
+
It has a Log-Structured-Merge-Database (LSM) design with flexible tradeoffs
|
|
12
|
+
between Write-Amplification-Factor (WAF), Read-Amplification-Factor (RAF)
|
|
13
|
+
and Space-Amplification-Factor (SAF). It has multi-threaded compactions,
|
|
14
|
+
making it especially suitable for storing multiple terabytes of data in a
|
|
15
|
+
single database.
|
|
16
|
+
|
|
17
|
+
Start with example usage here: https://github.com/facebook/rocksdb/tree/main/examples
|
|
18
|
+
|
|
19
|
+
See the [github wiki](https://github.com/facebook/rocksdb/wiki) for more explanation.
|
|
20
|
+
|
|
21
|
+
The public interface is in `include/`. Callers should not include or
|
|
22
|
+
rely on the details of any other header files in this package. Those
|
|
23
|
+
internal APIs may be changed without warning.
|
|
24
|
+
|
|
25
|
+
Questions and discussions are welcome on the [RocksDB Developers Public](https://www.facebook.com/groups/rocksdb.dev/) Facebook group and [email list](https://groups.google.com/g/rocksdb) on Google Groups.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
RocksDB is dual-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). You may select, at your option, one of the above-listed licenses.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# RocksDB Micro-Benchmark
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
RocksDB micro-benchmark is a set of tests for benchmarking a single component or simple DB operations. The test artificially generates input data and executes the same operation with it to collect and report performance metrics. As it's focusing on testing a single, well-defined operation, the result is more precise and reproducible, which also has its limitation of not representing a real production use case. The test author needs to carefully design the microbench to represent its true purpose.
|
|
6
|
+
|
|
7
|
+
The tests are based on [Google Benchmark](https://github.com/google/benchmark) library, which provides a standard framework for writing benchmarks.
|
|
8
|
+
|
|
9
|
+
## How to Run
|
|
10
|
+
### Prerequisite
|
|
11
|
+
Install the [Google Benchmark](https://github.com/google/benchmark) version `1.6.0` or above.
|
|
12
|
+
|
|
13
|
+
*Note: Google Benchmark `1.6.x` is incompatible with previous versions like `1.5.x`, please make sure you're using the newer version.*
|
|
14
|
+
|
|
15
|
+
### Build and Run
|
|
16
|
+
With `Makefile`:
|
|
17
|
+
```bash
|
|
18
|
+
$ DEBUG_LEVEL=0 make run_microbench
|
|
19
|
+
```
|
|
20
|
+
Or with cmake:
|
|
21
|
+
```bash
|
|
22
|
+
$ mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_BENCHMARK
|
|
23
|
+
$ make run_microbench
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
*Note: Please run the benchmark code in release build.*
|
|
27
|
+
### Run Single Test
|
|
28
|
+
Example:
|
|
29
|
+
```bash
|
|
30
|
+
$ make db_basic_bench
|
|
31
|
+
$ ./db_basic_bench --benchmark_filter=<TEST_NAME>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Best Practices
|
|
35
|
+
#### * Use the Same Test Directory Setting as Unittest
|
|
36
|
+
Most of the Micro-benchmark tests use the same test directory setup as unittest, so it could be overridden by:
|
|
37
|
+
```bash
|
|
38
|
+
$ TEST_TMPDIR=/mydata/tmp/ ./db_basic_bench --benchmark_filter=<TEST_NAME>
|
|
39
|
+
```
|
|
40
|
+
Please also follow that when designing new tests.
|
|
41
|
+
|
|
42
|
+
#### * Avoid Using Debug API
|
|
43
|
+
Even though micro-benchmark is a test, avoid using internal Debug API like TEST_WaitForRun() which is designed for unittest. As benchmark tests are designed for release build, don't use any of that.
|
|
44
|
+
|
|
45
|
+
#### * Pay Attention to Local Optimization
|
|
46
|
+
As a micro-benchmark is focusing on a single component or area, make sure it is a key part for impacting the overall application performance.
|
|
47
|
+
|
|
48
|
+
The compiler might be able to optimize the code that not the same way as the whole application, and if the test data input is simple and small, it may be able to all cached in CPU memory, which is leading to a wrong metric. Take these into consideration when designing the tests.
|
|
49
|
+
|
|
50
|
+
#### * Names of user-defined counters/metrics has to be `[A-Za-z0-9_]`
|
|
51
|
+
It's a restriction of the metrics collecting and reporting system RocksDB is using internally. It will also help integrate with more systems.
|
|
52
|
+
|
|
53
|
+
#### * Minimize the Metrics Variation
|
|
54
|
+
Try reducing the test result variation, one way to check that is running the test multiple times and check the CV (Coefficient of Variation) reported by gbenchmark.
|
|
55
|
+
```bash
|
|
56
|
+
$ ./db_basic_bench --benchmark_filter=<TEST_NAME> --benchmark_repetitions=10
|
|
57
|
+
...
|
|
58
|
+
<TEST_NAME>_cv 3.2%
|
|
59
|
+
```
|
|
60
|
+
RocksDB has background compaction jobs which may cause the test result to vary a lot. If the micro-benchmark is not purposely testing the operation while compaction is in progress, it should wait for the compaction to finish (`db_impl->WaitForCompact()`) or disable auto-compaction.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
## Building external plugins together with RocksDB
|
|
2
|
+
|
|
3
|
+
RocksDB offers several plugin interfaces for developers to customize its behavior. One difficulty developers face is how to make their plugin available to end users. The approach discussed here involves building the external code together with the RocksDB code into a single binary. Note another approach we plan to support involves loading plugins dynamically from shared libraries.
|
|
4
|
+
|
|
5
|
+
### Discovery
|
|
6
|
+
|
|
7
|
+
We hope developers will mention their work in "PLUGINS.md" so users can easily discover and reuse solutions for customizing RocksDB.
|
|
8
|
+
|
|
9
|
+
### Directory organization
|
|
10
|
+
|
|
11
|
+
External plugins will be linked according to their name into a subdirectory of "plugin/". For example, a plugin called "dedupfs" would be linked into "plugin/dedupfs/".
|
|
12
|
+
|
|
13
|
+
### Build standard
|
|
14
|
+
|
|
15
|
+
Currently the only supported build system are make and cmake.
|
|
16
|
+
|
|
17
|
+
For make, files in the plugin directory ending in the .mk extension can define the following variables.
|
|
18
|
+
|
|
19
|
+
* `$(PLUGIN_NAME)_SOURCES`: these files will be compiled and linked with RocksDB. They can access RocksDB public header files.
|
|
20
|
+
* `$(PLUGIN_NAME)_HEADERS`: these files will be installed in the RocksDB header directory. Their paths will be prefixed by "rocksdb/plugin/$(PLUGIN_NAME)/".
|
|
21
|
+
* `$(PLUGIN_NAME)_LDFLAGS`: these flags will be passed to the final link step. For example, library dependencies can be propagated here, or symbols can be forcibly included, e.g., for static registration.
|
|
22
|
+
* `$(PLUGIN_NAME)_CXXFLAGS`: these flags will be passed to the compiler. For example, they can specify locations of header files in non-standard locations.
|
|
23
|
+
|
|
24
|
+
Users will run the usual make commands from the RocksDB directory, specifying the plugins to include in a space-separated list in the variable `ROCKSDB_PLUGINS`.
|
|
25
|
+
|
|
26
|
+
For CMake, the CMakeLists.txt file in the plugin directory can define the following variables.
|
|
27
|
+
|
|
28
|
+
* `${PLUGIN_NAME}_SOURCES`: these files will be compiled and linked with RocksDB. They can access RocksDB public header files.
|
|
29
|
+
* `${PLUGIN_NAME}_COMPILE_FLAGS`: these flags will be passed to the compiler. For example, they can specify locations of header files in non-standard locations.
|
|
30
|
+
* `${PLUGIN_NAME}_INCLUDE_PATHS`: paths to directories to search for plugin-specific header files during compilation.
|
|
31
|
+
* `${PLUGIN_NAME}_LIBS`: list of library names required to build the plugin, e.g. `dl`, `java`, `jvm`, `rados`, etc. CMake will generate proper flags for linking.
|
|
32
|
+
* `${PLUGIN_NAME}_LINK_PATHS`: list of paths for the linker to search for required libraries in additional to standard locations.
|
|
33
|
+
* `${PLUGIN_NAME}_CMAKE_SHARED_LINKER_FLAGS` additional linker flags used to generate shared libraries. For example, symbols can be forcibly included, e.g., for static registration.
|
|
34
|
+
* `${PLUGIN_NAME}_CMAKE_EXE_LINKER_FLAGS`: additional linker flags used to generate executables. For example, symbols can be forcibly included, e.g., for static registration.
|
|
35
|
+
|
|
36
|
+
Users will run the usual cmake commands, specifying the plugins to include in a space-separated list in the command line variable `ROCKSDB_PLUGINS` when invoking cmake.
|
|
37
|
+
```
|
|
38
|
+
cmake .. -DROCKSDB_PLUGINS="dedupfs hdfs rados"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Example
|
|
42
|
+
|
|
43
|
+
For a working example, see [Dedupfs](https://github.com/ajkr/dedupfs).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
This directory contains interfaces and implementations that isolate the
|
|
2
|
+
rest of the package from platform details.
|
|
3
|
+
|
|
4
|
+
Code in the rest of the package includes "port.h" from this directory.
|
|
5
|
+
"port.h" in turn includes a platform specific "port_<platform>.h" file
|
|
6
|
+
that provides the platform specific implementation.
|
|
7
|
+
|
|
8
|
+
See port_posix.h for an example of what must be provided in a platform
|
|
9
|
+
specific header file.
|
|
10
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
The files in this directory originally come from
|
|
2
|
+
https://github.com/percona/PerconaFT/.
|
|
3
|
+
|
|
4
|
+
This directory only includes the "locktree" part of PerconaFT, and its
|
|
5
|
+
dependencies.
|
|
6
|
+
|
|
7
|
+
The following modifications were made:
|
|
8
|
+
- Make locktree usable outside of PerconaFT library
|
|
9
|
+
- Add shared read-only lock support
|
|
10
|
+
|
|
11
|
+
The files named *_subst.* are substitutes of the PerconaFT's files, they
|
|
12
|
+
contain replacements of PerconaFT's functionality.
|
|
13
|
+
|
package/index.js
CHANGED
|
@@ -171,6 +171,10 @@ class RocksLevel extends AbstractLevel {
|
|
|
171
171
|
return callback[kPromise]
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
_getManySync (keys, options) {
|
|
175
|
+
return binding.db_get_many_sync(this[kContext], keys, options ?? EMPTY)
|
|
176
|
+
}
|
|
177
|
+
|
|
174
178
|
_getMergeOperands (key, options, callback) {
|
|
175
179
|
callback = fromCallback(callback, kPromise)
|
|
176
180
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/rocksdb",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.1",
|
|
4
4
|
"description": "A low-level Node.js RocksDB binding",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"du": "^1.0.0",
|
|
28
28
|
"faucet": "^0.0.3",
|
|
29
29
|
"glob": "^8.0.3",
|
|
30
|
+
"lru-cache": "^11.0.0",
|
|
31
|
+
"mitata": "^0.1.11",
|
|
30
32
|
"mkfiletree": "^2.0.0",
|
|
31
33
|
"node-gyp": "^9.3.0",
|
|
32
34
|
"nyc": "^15.0.0",
|
|
Binary file
|
|
Binary file
|
package/tmp/000099.sst
ADDED
|
Binary file
|
package/tmp/000102.sst
ADDED
|
Binary file
|
package/tmp/000103.log
ADDED
|
Binary file
|
package/tmp/CURRENT
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MANIFEST-000104
|
package/tmp/IDENTITY
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
6d5096a1-16eb-423d-8e1e-c703b4fdbc14
|
package/tmp/LOCK
ADDED
|
File without changes
|
|
Binary file
|