@nxtedition/rocksdb 7.0.0-alpha.7 → 7.0.0-alpha.8
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/binding.cc
CHANGED
|
@@ -691,85 +691,85 @@ struct OpenWorker final : public Worker {
|
|
|
691
691
|
std::vector<rocksdb::ColumnFamilyDescriptor> column_families_;
|
|
692
692
|
};
|
|
693
693
|
|
|
694
|
-
napi_status InitOptions(napi_env env, auto&
|
|
695
|
-
const auto memtable_memory_budget = Uint32Property(env,
|
|
694
|
+
napi_status InitOptions(napi_env env, auto& columnOptions, auto options) {
|
|
695
|
+
const auto memtable_memory_budget = Uint32Property(env, options, "memtableMemoryBudget").value_or(256 * 1024 * 1024);
|
|
696
696
|
|
|
697
|
-
const auto compaction = StringProperty(env,
|
|
697
|
+
const auto compaction = StringProperty(env, options, "compaction").value_or("level");
|
|
698
698
|
|
|
699
699
|
if (compaction == "universal") {
|
|
700
|
-
|
|
700
|
+
columnOptions.write_buffer_size = static_cast<size_t>(memtable_memory_budget / 4);
|
|
701
701
|
// merge two memtables when flushing to L0
|
|
702
|
-
|
|
702
|
+
columnOptions.min_write_buffer_number_to_merge = 2;
|
|
703
703
|
// this means we'll use 50% extra memory in the worst case, but will reduce
|
|
704
704
|
// write stalls.
|
|
705
|
-
|
|
705
|
+
columnOptions.max_write_buffer_number = 6;
|
|
706
706
|
// universal style compaction
|
|
707
|
-
|
|
708
|
-
|
|
707
|
+
columnOptions.compaction_style = rocksdb::kCompactionStyleUniversal;
|
|
708
|
+
columnOptions.compaction_options_universal.compression_size_percent = 80;
|
|
709
709
|
} else {
|
|
710
710
|
// merge two memtables when flushing to L0
|
|
711
|
-
|
|
711
|
+
columnOptions.min_write_buffer_number_to_merge = 2;
|
|
712
712
|
// this means we'll use 50% extra memory in the worst case, but will reduce
|
|
713
713
|
// write stalls.
|
|
714
|
-
|
|
714
|
+
columnOptions.max_write_buffer_number = 6;
|
|
715
715
|
// start flushing L0->L1 as soon as possible. each file on level0 is
|
|
716
716
|
// (memtable_memory_budget / 2). This will flush level 0 when it's bigger than
|
|
717
717
|
// memtable_memory_budget.
|
|
718
|
-
|
|
718
|
+
columnOptions.level0_file_num_compaction_trigger = 2;
|
|
719
719
|
// doesn't really matter much, but we don't want to create too many files
|
|
720
|
-
|
|
720
|
+
columnOptions.target_file_size_base = memtable_memory_budget / 8;
|
|
721
721
|
// make Level1 size equal to Level0 size, so that L0->L1 compactions are fast
|
|
722
|
-
|
|
722
|
+
columnOptions.max_bytes_for_level_base = memtable_memory_budget;
|
|
723
723
|
|
|
724
724
|
// level style compaction
|
|
725
|
-
|
|
725
|
+
columnOptions.compaction_style = rocksdb::kCompactionStyleLevel;
|
|
726
726
|
|
|
727
727
|
// TODO (perf): only compress levels >= 2
|
|
728
728
|
}
|
|
729
729
|
|
|
730
|
-
|
|
731
|
-
BooleanProperty(env,
|
|
732
|
-
if (
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
//
|
|
730
|
+
columnOptions.compression =
|
|
731
|
+
BooleanProperty(env, options, "compression").value_or((true)) ? rocksdb::kZSTD : rocksdb::kNoCompression;
|
|
732
|
+
if (columnOptions.compression == rocksdb::kZSTD) {
|
|
733
|
+
columnOptions.compression_opts.max_dict_bytes = 16 * 1024;
|
|
734
|
+
columnOptions.compression_opts.zstd_max_train_bytes = 16 * 1024 * 100;
|
|
735
|
+
// columnOptions.compression_opts.parallel_threads
|
|
736
736
|
}
|
|
737
737
|
|
|
738
|
-
const auto cacheSize = Uint32Property(env,
|
|
738
|
+
const auto cacheSize = Uint32Property(env, options, "cacheSize").value_or(8 << 20);
|
|
739
739
|
|
|
740
740
|
rocksdb::BlockBasedTableOptions tableOptions;
|
|
741
741
|
|
|
742
742
|
if (cacheSize) {
|
|
743
743
|
tableOptions.block_cache = rocksdb::NewLRUCache(cacheSize);
|
|
744
744
|
tableOptions.cache_index_and_filter_blocks =
|
|
745
|
-
BooleanProperty(env,
|
|
745
|
+
BooleanProperty(env, options, "cacheIndexAndFilterBlocks").value_or(true);
|
|
746
746
|
} else {
|
|
747
747
|
tableOptions.no_block_cache = true;
|
|
748
748
|
tableOptions.cache_index_and_filter_blocks = false;
|
|
749
749
|
}
|
|
750
750
|
|
|
751
|
-
const auto optimize = StringProperty(env,
|
|
751
|
+
const auto optimize = StringProperty(env, options, "optimize").value_or("");
|
|
752
752
|
|
|
753
753
|
if (optimize == "point-lookup") {
|
|
754
754
|
tableOptions.data_block_index_type = rocksdb::BlockBasedTableOptions::kDataBlockBinaryAndHash;
|
|
755
755
|
tableOptions.data_block_hash_table_util_ratio = 0.75;
|
|
756
756
|
tableOptions.filter_policy.reset(rocksdb::NewRibbonFilterPolicy(10, 1));
|
|
757
757
|
|
|
758
|
-
|
|
759
|
-
|
|
758
|
+
columnOptions.memtable_prefix_bloom_size_ratio = 0.02;
|
|
759
|
+
columnOptions.memtable_whole_key_filtering = true;
|
|
760
760
|
} else if (optimize == "range-lookup") {
|
|
761
761
|
// TODO?
|
|
762
762
|
} else {
|
|
763
763
|
tableOptions.filter_policy.reset(rocksdb::NewRibbonFilterPolicy(10));
|
|
764
764
|
}
|
|
765
765
|
|
|
766
|
-
tableOptions.block_size = Uint32Property(env,
|
|
767
|
-
tableOptions.block_restart_interval = Uint32Property(env,
|
|
766
|
+
tableOptions.block_size = Uint32Property(env, options, "blockSize").value_or(4096);
|
|
767
|
+
tableOptions.block_restart_interval = Uint32Property(env, options, "blockRestartInterval").value_or(16);
|
|
768
768
|
tableOptions.format_version = 5;
|
|
769
769
|
tableOptions.checksum = rocksdb::kXXH3;
|
|
770
|
-
tableOptions.optimize_filters_for_memory = BooleanProperty(env,
|
|
770
|
+
tableOptions.optimize_filters_for_memory = BooleanProperty(env, options, "optimizeFiltersForMemory").value_or(true);
|
|
771
771
|
|
|
772
|
-
|
|
772
|
+
columnOptions.table_factory.reset(rocksdb::NewBlockBasedTableFactory(tableOptions));
|
|
773
773
|
|
|
774
774
|
return napi_ok;
|
|
775
775
|
}
|
|
@@ -791,7 +791,7 @@ NAPI_METHOD(db_open) {
|
|
|
791
791
|
|
|
792
792
|
dbOptions.create_if_missing = BooleanProperty(env, options, "createIfMissing").value_or(true);
|
|
793
793
|
dbOptions.error_if_exists = BooleanProperty(env, options, "errorIfExists").value_or(false);
|
|
794
|
-
dbOptions.avoid_unnecessary_blocking_io = true;
|
|
794
|
+
dbOptions.avoid_unnecessary_blocking_io = BooleanProperty(env, options, "avoidUnnecessaryBlockingIO").value_or(true);
|
|
795
795
|
dbOptions.use_adaptive_mutex = BooleanProperty(env, options, "useAdaptiveMutex").value_or(true);
|
|
796
796
|
dbOptions.enable_pipelined_write = BooleanProperty(env, options, "enablePipelinedWrite").value_or(true);
|
|
797
797
|
dbOptions.max_background_jobs =
|
|
@@ -799,6 +799,7 @@ NAPI_METHOD(db_open) {
|
|
|
799
799
|
dbOptions.WAL_ttl_seconds = Uint32Property(env, options, "walTTL").value_or(0) / 1e3;
|
|
800
800
|
dbOptions.WAL_size_limit_MB = Uint32Property(env, options, "walSizeLimit").value_or(0) / 1e6;
|
|
801
801
|
dbOptions.create_missing_column_families = true;
|
|
802
|
+
dbOptions.unordered_write = BooleanProperty(env, options, "unorderedWrite").value_or(false);
|
|
802
803
|
|
|
803
804
|
const auto infoLogLevel = StringProperty(env, options, "infoLogLevel").value_or("");
|
|
804
805
|
if (infoLogLevel.size() > 0) {
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|