@nxtedition/rocksdb 8.2.0-alpha.1 → 8.2.0
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 +11 -74
- package/binding.gyp +7 -5
- package/deps/rocksdb/rocksdb/CMakeLists.txt +4 -0
- package/deps/rocksdb/rocksdb/TARGETS +7 -0
- package/deps/rocksdb/rocksdb/cache/cache.cc +43 -0
- package/deps/rocksdb/rocksdb/cache/cache_bench_tool.cc +8 -5
- package/deps/rocksdb/rocksdb/cache/cache_entry_stats.h +1 -1
- package/deps/rocksdb/rocksdb/cache/cache_reservation_manager.cc +1 -1
- package/deps/rocksdb/rocksdb/cache/cache_test.cc +12 -48
- package/deps/rocksdb/rocksdb/cache/charged_cache.cc +26 -18
- package/deps/rocksdb/rocksdb/cache/charged_cache.h +5 -62
- package/deps/rocksdb/rocksdb/cache/clock_cache.cc +119 -44
- package/deps/rocksdb/rocksdb/cache/clock_cache.h +34 -29
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.cc +3 -3
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.h +2 -2
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache_test.cc +148 -209
- package/deps/rocksdb/rocksdb/cache/lru_cache.cc +118 -284
- package/deps/rocksdb/rocksdb/cache/lru_cache.h +23 -71
- package/deps/rocksdb/rocksdb/cache/lru_cache_test.cc +351 -392
- package/deps/rocksdb/rocksdb/cache/secondary_cache.cc +5 -2
- package/deps/rocksdb/rocksdb/cache/secondary_cache_adapter.cc +296 -0
- package/deps/rocksdb/rocksdb/cache/secondary_cache_adapter.h +52 -0
- package/deps/rocksdb/rocksdb/cache/sharded_cache.h +22 -19
- package/deps/rocksdb/rocksdb/cache/typed_cache.h +56 -20
- package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +3 -0
- package/deps/rocksdb/rocksdb/db/blob/blob_counting_iterator.h +4 -0
- package/deps/rocksdb/rocksdb/db/blob/blob_source.cc +3 -3
- package/deps/rocksdb/rocksdb/db/blob/blob_source_test.cc +19 -25
- package/deps/rocksdb/rocksdb/db/blob/db_blob_basic_test.cc +216 -0
- package/deps/rocksdb/rocksdb/db/c.cc +90 -1
- package/deps/rocksdb/rocksdb/db/column_family.cc +8 -7
- package/deps/rocksdb/rocksdb/db/column_family.h +0 -6
- package/deps/rocksdb/rocksdb/db/compaction/clipping_iterator.h +5 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +24 -7
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +17 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +18 -12
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +3 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.cc +245 -302
- package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.h +13 -2
- package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.h +5 -0
- package/deps/rocksdb/rocksdb/db/db_basic_test.cc +75 -15
- package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +2 -3
- package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +1 -5
- package/deps/rocksdb/rocksdb/db/db_flush_test.cc +91 -1
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +5 -12
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +16 -4
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +47 -24
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +4 -2
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +32 -3
- package/deps/rocksdb/rocksdb/db/db_iter.cc +28 -29
- package/deps/rocksdb/rocksdb/db/db_iter.h +0 -3
- package/deps/rocksdb/rocksdb/db/db_properties_test.cc +176 -0
- package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +391 -2
- package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +26 -0
- package/deps/rocksdb/rocksdb/db/db_write_test.cc +13 -5
- package/deps/rocksdb/rocksdb/db/dbformat.h +3 -1
- package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +0 -1
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +0 -6
- package/deps/rocksdb/rocksdb/db/forward_iterator.cc +3 -0
- package/deps/rocksdb/rocksdb/db/forward_iterator.h +1 -1
- package/deps/rocksdb/rocksdb/db/history_trimming_iterator.h +4 -0
- package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +68 -40
- package/deps/rocksdb/rocksdb/db/import_column_family_job.h +3 -3
- package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +115 -0
- package/deps/rocksdb/rocksdb/db/internal_stats.cc +169 -72
- package/deps/rocksdb/rocksdb/db/internal_stats.h +36 -7
- package/deps/rocksdb/rocksdb/db/memtable.cc +6 -4
- package/deps/rocksdb/rocksdb/db/merge_helper.cc +4 -0
- package/deps/rocksdb/rocksdb/db/perf_context_test.cc +151 -0
- package/deps/rocksdb/rocksdb/db/range_del_aggregator.cc +47 -16
- package/deps/rocksdb/rocksdb/db/range_del_aggregator.h +10 -8
- package/deps/rocksdb/rocksdb/db/range_del_aggregator_test.cc +91 -93
- package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.h +1 -2
- package/deps/rocksdb/rocksdb/db/version_edit_handler.cc +1 -1
- package/deps/rocksdb/rocksdb/db/version_set.cc +30 -14
- package/deps/rocksdb/rocksdb/db/version_set.h +1 -0
- package/deps/rocksdb/rocksdb/db/write_stall_stats.cc +179 -0
- package/deps/rocksdb/rocksdb/db/write_stall_stats.h +47 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +109 -7
- package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +147 -12
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +31 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +22 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +4 -1
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +42 -59
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +7 -4
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +7 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/expected_state.cc +6 -10
- package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.cc +6 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.h +4 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +127 -36
- package/deps/rocksdb/rocksdb/env/fs_posix.cc +8 -0
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +35 -0
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +29 -8
- package/deps/rocksdb/rocksdb/file/file_util.cc +14 -10
- package/deps/rocksdb/rocksdb/file/prefetch_test.cc +183 -63
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_cache.h +159 -66
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +3 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/c.h +52 -5
- package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +3 -3
- package/deps/rocksdb/rocksdb/include/rocksdb/compaction_filter.h +134 -73
- package/deps/rocksdb/rocksdb/include/rocksdb/db.h +46 -3
- package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +6 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/listener.h +0 -6
- package/deps/rocksdb/rocksdb/include/rocksdb/metadata.h +7 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/options.h +2 -2
- package/deps/rocksdb/rocksdb/include/rocksdb/perf_context.h +6 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/secondary_cache.h +3 -3
- package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +18 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/types.h +28 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
- package/deps/rocksdb/rocksdb/include/rocksdb/wide_columns.h +39 -0
- package/deps/rocksdb/rocksdb/monitoring/perf_context.cc +5 -0
- package/deps/rocksdb/rocksdb/monitoring/statistics.cc +9 -1
- package/deps/rocksdb/rocksdb/options/customizable_test.cc +2 -2
- package/deps/rocksdb/rocksdb/port/stack_trace.cc +17 -7
- package/deps/rocksdb/rocksdb/port/win/env_win.h +1 -0
- package/deps/rocksdb/rocksdb/src.mk +4 -0
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +38 -34
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +11 -12
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +5 -5
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +126 -132
- package/deps/rocksdb/rocksdb/table/block_based/block_cache.cc +16 -16
- package/deps/rocksdb/rocksdb/table/block_based/cachable_entry.h +0 -16
- package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +1 -1
- package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +1 -1
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +3 -4
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +1 -1
- package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +1 -1
- package/deps/rocksdb/rocksdb/table/compaction_merging_iterator.cc +370 -0
- package/deps/rocksdb/rocksdb/table/compaction_merging_iterator.h +44 -0
- package/deps/rocksdb/rocksdb/table/get_context.cc +4 -2
- package/deps/rocksdb/rocksdb/table/merging_iterator.cc +555 -267
- package/deps/rocksdb/rocksdb/table/merging_iterator.h +10 -5
- package/deps/rocksdb/rocksdb/table/table_test.cc +113 -70
- package/deps/rocksdb/rocksdb/test_util/secondary_cache_test_util.cc +96 -0
- package/deps/rocksdb/rocksdb/test_util/secondary_cache_test_util.h +117 -0
- package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_impl.cc +5 -3
- package/deps/rocksdb/rocksdb/utilities/fault_injection_secondary_cache.cc +3 -3
- package/deps/rocksdb/rocksdb/utilities/fault_injection_secondary_cache.h +1 -1
- package/deps/rocksdb/rocksdb/utilities/simulator_cache/sim_cache.cc +9 -2
- package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.cc +5 -1
- package/deps/rocksdb/rocksdb/utilities/ttl/ttl_test.cc +11 -0
- package/deps/rocksdb/rocksdb.gyp +6 -7
- package/index.js +0 -6
- package/package.json +1 -1
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/deps/liburing/liburing.gyp +0 -20
- package/tmp/test.js +0 -7
package/binding.cc
CHANGED
|
@@ -383,7 +383,7 @@ struct BaseIterator : public Closable {
|
|
|
383
383
|
}
|
|
384
384
|
readOptions.fill_cache = fillCache_;
|
|
385
385
|
readOptions.snapshot = snapshot_.get();
|
|
386
|
-
readOptions.async_io = true;
|
|
386
|
+
// readOptions.async_io = true;
|
|
387
387
|
readOptions.adaptive_readahead = true;
|
|
388
388
|
readOptions.tailing = tailing_;
|
|
389
389
|
|
|
@@ -468,13 +468,7 @@ static void FinalizeDatabase(napi_env env, void* data, void* hint) {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
#include <liburing.h>
|
|
472
|
-
#include <iostream>
|
|
473
|
-
|
|
474
471
|
NAPI_METHOD(db_init) {
|
|
475
|
-
struct io_uring* new_io_uring = new struct io_uring;
|
|
476
|
-
std::cerr << "###############" << io_uring_queue_init(256, new_io_uring, 0);
|
|
477
|
-
|
|
478
472
|
auto database = new Database();
|
|
479
473
|
napi_add_env_cleanup_hook(env, env_cleanup_hook, database);
|
|
480
474
|
|
|
@@ -648,8 +642,8 @@ NAPI_METHOD(db_get_merge_operands) {
|
|
|
648
642
|
Database* database;
|
|
649
643
|
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
|
|
650
644
|
|
|
651
|
-
|
|
652
|
-
|
|
645
|
+
std::string key;
|
|
646
|
+
NAPI_STATUS_THROWS(GetValue(env, argv[1], key));
|
|
653
647
|
|
|
654
648
|
const auto options = argv[2];
|
|
655
649
|
|
|
@@ -666,22 +660,16 @@ NAPI_METHOD(db_get_merge_operands) {
|
|
|
666
660
|
[=, key = std::move(key)](auto& values) {
|
|
667
661
|
rocksdb::ReadOptions readOptions;
|
|
668
662
|
|
|
669
|
-
|
|
663
|
+
values.resize(16); // TODO (fix): Make option
|
|
670
664
|
|
|
671
|
-
|
|
672
|
-
|
|
665
|
+
rocksdb::GetMergeOperandsOptions mergeOperandsOptions;
|
|
666
|
+
mergeOperandsOptions.expected_max_number_of_operands = values.size();
|
|
673
667
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
column,
|
|
678
|
-
key,
|
|
679
|
-
values.data(),
|
|
680
|
-
&mergeOperandsOptions,
|
|
681
|
-
&size
|
|
682
|
-
);
|
|
668
|
+
int size = 0;
|
|
669
|
+
const auto status =
|
|
670
|
+
database->db->GetMergeOperands(readOptions, column, key, values.data(), &mergeOperandsOptions, &size);
|
|
683
671
|
|
|
684
|
-
|
|
672
|
+
values.resize(size);
|
|
685
673
|
|
|
686
674
|
return status;
|
|
687
675
|
},
|
|
@@ -921,7 +909,7 @@ NAPI_METHOD(db_get_many) {
|
|
|
921
909
|
rocksdb::ReadOptions readOptions;
|
|
922
910
|
readOptions.fill_cache = fillCache;
|
|
923
911
|
readOptions.snapshot = snapshot.get();
|
|
924
|
-
readOptions.async_io = true;
|
|
912
|
+
// readOptions.async_io = true;
|
|
925
913
|
readOptions.ignore_range_deletions = ignoreRangeDeletions;
|
|
926
914
|
readOptions.optimize_multiget_for_io = true;
|
|
927
915
|
|
|
@@ -1571,55 +1559,6 @@ NAPI_METHOD(batch_iterate) {
|
|
|
1571
1559
|
return result;
|
|
1572
1560
|
}
|
|
1573
1561
|
|
|
1574
|
-
NAPI_METHOD(db_get_sorted_wal_files) {
|
|
1575
|
-
NAPI_ARGV(3);
|
|
1576
|
-
|
|
1577
|
-
Database* database;
|
|
1578
|
-
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
|
|
1579
|
-
|
|
1580
|
-
auto callback = argv[1];
|
|
1581
|
-
|
|
1582
|
-
runAsync<rocksdb::VectorLogPtr>(
|
|
1583
|
-
"leveldown.open", env, callback, [=](auto& files) { return database->db->GetSortedWalFiles(files); },
|
|
1584
|
-
[=](auto& files, auto env, auto& argv) {
|
|
1585
|
-
argv.resize(2);
|
|
1586
|
-
|
|
1587
|
-
const auto size = files.size();
|
|
1588
|
-
NAPI_STATUS_RETURN(napi_create_array_with_length(env, size, &argv[1]));
|
|
1589
|
-
|
|
1590
|
-
for (size_t n = 0; n < size; ++n) {
|
|
1591
|
-
napi_value element;
|
|
1592
|
-
NAPI_STATUS_RETURN(napi_create_object(env, &element));
|
|
1593
|
-
|
|
1594
|
-
napi_value pathName;
|
|
1595
|
-
NAPI_STATUS_RETURN(napi_create_string_utf8(env, files[n]->PathName().data(), NAPI_AUTO_LENGTH, &pathName))
|
|
1596
|
-
NAPI_STATUS_RETURN(napi_set_named_property(env, element, "pathName", pathName));
|
|
1597
|
-
|
|
1598
|
-
napi_value logNumber;
|
|
1599
|
-
NAPI_STATUS_RETURN(napi_create_int32(env, files[n]->LogNumber(), &logNumber))
|
|
1600
|
-
NAPI_STATUS_RETURN(napi_set_named_property(env, element, "logNumber", logNumber));
|
|
1601
|
-
|
|
1602
|
-
napi_value type;
|
|
1603
|
-
NAPI_STATUS_RETURN(napi_create_int32(env, files[n]->Type(), &type))
|
|
1604
|
-
NAPI_STATUS_RETURN(napi_set_named_property(env, element, "type", type));
|
|
1605
|
-
|
|
1606
|
-
napi_value startSequence;
|
|
1607
|
-
NAPI_STATUS_RETURN(napi_create_int64(env, files[n]->StartSequence(), &startSequence))
|
|
1608
|
-
NAPI_STATUS_RETURN(napi_set_named_property(env, element, "startSequence", startSequence));
|
|
1609
|
-
|
|
1610
|
-
napi_value sizeFileBytes;
|
|
1611
|
-
NAPI_STATUS_RETURN(napi_create_int64(env, files[n]->SizeFileBytes(), &sizeFileBytes))
|
|
1612
|
-
NAPI_STATUS_RETURN(napi_set_named_property(env, element, "sizeFileBytes", sizeFileBytes));
|
|
1613
|
-
|
|
1614
|
-
NAPI_STATUS_RETURN(napi_set_element(env, argv[1], n, element));
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
return napi_ok;
|
|
1618
|
-
});
|
|
1619
|
-
|
|
1620
|
-
return 0;
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
1562
|
NAPI_METHOD(db_flush_wal) {
|
|
1624
1563
|
NAPI_ARGV(3);
|
|
1625
1564
|
|
|
@@ -1640,7 +1579,6 @@ NAPI_METHOD(db_flush_wal) {
|
|
|
1640
1579
|
return 0;
|
|
1641
1580
|
}
|
|
1642
1581
|
|
|
1643
|
-
|
|
1644
1582
|
NAPI_INIT() {
|
|
1645
1583
|
NAPI_EXPORT_FUNCTION(db_init);
|
|
1646
1584
|
NAPI_EXPORT_FUNCTION(db_open);
|
|
@@ -1650,7 +1588,6 @@ NAPI_INIT() {
|
|
|
1650
1588
|
NAPI_EXPORT_FUNCTION(db_clear);
|
|
1651
1589
|
NAPI_EXPORT_FUNCTION(db_get_property);
|
|
1652
1590
|
NAPI_EXPORT_FUNCTION(db_get_latest_sequence);
|
|
1653
|
-
NAPI_EXPORT_FUNCTION(db_get_sorted_wal_files);
|
|
1654
1591
|
NAPI_EXPORT_FUNCTION(db_flush_wal);
|
|
1655
1592
|
NAPI_EXPORT_FUNCTION(db_get_merge_operands);
|
|
1656
1593
|
|
package/binding.gyp
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"-mbmi",
|
|
16
16
|
"-mlzcnt"
|
|
17
17
|
],
|
|
18
|
+
"include_dirs": [
|
|
19
|
+
"/usr/lib/x86_64-linux-gnu/include",
|
|
20
|
+
"/usr/lib/include",
|
|
21
|
+
# "/usr/local/Cellar/jemalloc/5.3.0/include"
|
|
22
|
+
],
|
|
18
23
|
"ccflags": ["-flto"],
|
|
19
24
|
"cflags!": ["-fno-exceptions"],
|
|
20
25
|
"cflags_cc!": ["-fno-exceptions"],
|
|
@@ -46,11 +51,8 @@
|
|
|
46
51
|
}
|
|
47
52
|
]
|
|
48
53
|
],
|
|
49
|
-
"dependencies": [
|
|
50
|
-
|
|
51
|
-
"<(module_root_dir)/deps/liburing/liburing.gyp:liburing"
|
|
52
|
-
],
|
|
53
|
-
"include_dirs": ["<!(node -e \"require('napi-macros')\")",],
|
|
54
|
+
"dependencies": ["<(module_root_dir)/deps/rocksdb/rocksdb.gyp:rocksdb"],
|
|
55
|
+
"include_dirs": ["<!(node -e \"require('napi-macros')\")"],
|
|
54
56
|
"sources": ["binding.cc"]
|
|
55
57
|
}
|
|
56
58
|
]
|
|
@@ -661,6 +661,7 @@ set(SOURCES
|
|
|
661
661
|
cache/compressed_secondary_cache.cc
|
|
662
662
|
cache/lru_cache.cc
|
|
663
663
|
cache/secondary_cache.cc
|
|
664
|
+
cache/secondary_cache_adapter.cc
|
|
664
665
|
cache/sharded_cache.cc
|
|
665
666
|
db/arena_wrapped_db_iter.cc
|
|
666
667
|
db/blob/blob_contents.cc
|
|
@@ -747,6 +748,7 @@ set(SOURCES
|
|
|
747
748
|
db/write_batch.cc
|
|
748
749
|
db/write_batch_base.cc
|
|
749
750
|
db/write_controller.cc
|
|
751
|
+
db/write_stall_stats.cc
|
|
750
752
|
db/write_thread.cc
|
|
751
753
|
env/composite_env.cc
|
|
752
754
|
env/env.cc
|
|
@@ -838,6 +840,7 @@ set(SOURCES
|
|
|
838
840
|
table/get_context.cc
|
|
839
841
|
table/iterator.cc
|
|
840
842
|
table/merging_iterator.cc
|
|
843
|
+
table/compaction_merging_iterator.cc
|
|
841
844
|
table/meta_blocks.cc
|
|
842
845
|
table/persistent_cache_helper.cc
|
|
843
846
|
table/plain/plain_table_bloom.cc
|
|
@@ -1278,6 +1281,7 @@ if(WITH_TESTS OR WITH_BENCHMARK_TOOLS)
|
|
|
1278
1281
|
add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest)
|
|
1279
1282
|
add_library(testharness STATIC
|
|
1280
1283
|
test_util/mock_time_env.cc
|
|
1284
|
+
test_util/secondary_cache_test_util.cc
|
|
1281
1285
|
test_util/testharness.cc)
|
|
1282
1286
|
target_link_libraries(testharness gtest)
|
|
1283
1287
|
endif()
|
|
@@ -19,6 +19,7 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
|
|
19
19
|
"cache/compressed_secondary_cache.cc",
|
|
20
20
|
"cache/lru_cache.cc",
|
|
21
21
|
"cache/secondary_cache.cc",
|
|
22
|
+
"cache/secondary_cache_adapter.cc",
|
|
22
23
|
"cache/sharded_cache.cc",
|
|
23
24
|
"db/arena_wrapped_db_iter.cc",
|
|
24
25
|
"db/blob/blob_contents.cc",
|
|
@@ -105,6 +106,7 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
|
|
105
106
|
"db/write_batch.cc",
|
|
106
107
|
"db/write_batch_base.cc",
|
|
107
108
|
"db/write_controller.cc",
|
|
109
|
+
"db/write_stall_stats.cc",
|
|
108
110
|
"db/write_thread.cc",
|
|
109
111
|
"env/composite_env.cc",
|
|
110
112
|
"env/env.cc",
|
|
@@ -200,6 +202,7 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
|
|
200
202
|
"table/block_based/reader_common.cc",
|
|
201
203
|
"table/block_based/uncompression_dict_reader.cc",
|
|
202
204
|
"table/block_fetcher.cc",
|
|
205
|
+
"table/compaction_merging_iterator.cc",
|
|
203
206
|
"table/cuckoo/cuckoo_table_builder.cc",
|
|
204
207
|
"table/cuckoo/cuckoo_table_factory.cc",
|
|
205
208
|
"table/cuckoo/cuckoo_table_reader.cc",
|
|
@@ -362,6 +365,7 @@ cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[
|
|
|
362
365
|
"cache/compressed_secondary_cache.cc",
|
|
363
366
|
"cache/lru_cache.cc",
|
|
364
367
|
"cache/secondary_cache.cc",
|
|
368
|
+
"cache/secondary_cache_adapter.cc",
|
|
365
369
|
"cache/sharded_cache.cc",
|
|
366
370
|
"db/arena_wrapped_db_iter.cc",
|
|
367
371
|
"db/blob/blob_contents.cc",
|
|
@@ -448,6 +452,7 @@ cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[
|
|
|
448
452
|
"db/write_batch.cc",
|
|
449
453
|
"db/write_batch_base.cc",
|
|
450
454
|
"db/write_controller.cc",
|
|
455
|
+
"db/write_stall_stats.cc",
|
|
451
456
|
"db/write_thread.cc",
|
|
452
457
|
"env/composite_env.cc",
|
|
453
458
|
"env/env.cc",
|
|
@@ -543,6 +548,7 @@ cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[
|
|
|
543
548
|
"table/block_based/reader_common.cc",
|
|
544
549
|
"table/block_based/uncompression_dict_reader.cc",
|
|
545
550
|
"table/block_fetcher.cc",
|
|
551
|
+
"table/compaction_merging_iterator.cc",
|
|
546
552
|
"table/cuckoo/cuckoo_table_builder.cc",
|
|
547
553
|
"table/cuckoo/cuckoo_table_factory.cc",
|
|
548
554
|
"table/cuckoo/cuckoo_table_reader.cc",
|
|
@@ -699,6 +705,7 @@ cpp_library_wrapper(name="rocksdb_test_lib", srcs=[
|
|
|
699
705
|
"db/db_with_timestamp_test_util.cc",
|
|
700
706
|
"table/mock_table.cc",
|
|
701
707
|
"test_util/mock_time_env.cc",
|
|
708
|
+
"test_util/secondary_cache_test_util.cc",
|
|
702
709
|
"test_util/testharness.cc",
|
|
703
710
|
"test_util/testutil.cc",
|
|
704
711
|
"tools/block_cache_analyzer/block_cache_trace_analyzer.cc",
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
#include "util/string_util.h"
|
|
17
17
|
|
|
18
18
|
namespace ROCKSDB_NAMESPACE {
|
|
19
|
+
const Cache::CacheItemHelper kNoopCacheItemHelper{};
|
|
20
|
+
|
|
19
21
|
static std::unordered_map<std::string, OptionTypeInfo>
|
|
20
22
|
lru_cache_options_type_info = {
|
|
21
23
|
{"capacity",
|
|
@@ -112,4 +114,45 @@ Status Cache::CreateFromString(const ConfigOptions& config_options,
|
|
|
112
114
|
}
|
|
113
115
|
return status;
|
|
114
116
|
}
|
|
117
|
+
|
|
118
|
+
bool Cache::AsyncLookupHandle::IsReady() {
|
|
119
|
+
return pending_handle == nullptr || pending_handle->IsReady();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
bool Cache::AsyncLookupHandle::IsPending() { return pending_handle != nullptr; }
|
|
123
|
+
|
|
124
|
+
Cache::Handle* Cache::AsyncLookupHandle::Result() {
|
|
125
|
+
assert(!IsPending());
|
|
126
|
+
return result_handle;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
void Cache::StartAsyncLookup(AsyncLookupHandle& async_handle) {
|
|
130
|
+
async_handle.found_dummy_entry = false; // in case re-used
|
|
131
|
+
assert(!async_handle.IsPending());
|
|
132
|
+
async_handle.result_handle =
|
|
133
|
+
Lookup(async_handle.key, async_handle.helper, async_handle.create_context,
|
|
134
|
+
async_handle.priority, async_handle.stats);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
Cache::Handle* Cache::Wait(AsyncLookupHandle& async_handle) {
|
|
138
|
+
WaitAll(&async_handle, 1);
|
|
139
|
+
return async_handle.Result();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
void Cache::WaitAll(AsyncLookupHandle* async_handles, size_t count) {
|
|
143
|
+
for (size_t i = 0; i < count; ++i) {
|
|
144
|
+
if (async_handles[i].IsPending()) {
|
|
145
|
+
// If a pending handle gets here, it should be marked at "to be handled
|
|
146
|
+
// by a caller" by that caller erasing the pending_cache on it.
|
|
147
|
+
assert(async_handles[i].pending_cache == nullptr);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
void Cache::SetEvictionCallback(EvictionCallback&& fn) {
|
|
153
|
+
// Overwriting non-empty with non-empty could indicate a bug
|
|
154
|
+
assert(!eviction_callback_ || !fn);
|
|
155
|
+
eviction_callback_ = std::move(fn);
|
|
156
|
+
}
|
|
157
|
+
|
|
115
158
|
} // namespace ROCKSDB_NAMESPACE
|
|
@@ -255,12 +255,15 @@ void DeleteFn(Cache::ObjectPtr value, MemoryAllocator* /*alloc*/) {
|
|
|
255
255
|
delete[] static_cast<char*>(value);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
Cache::CacheItemHelper helper1_wos(CacheEntryRole::kDataBlock, DeleteFn);
|
|
258
259
|
Cache::CacheItemHelper helper1(CacheEntryRole::kDataBlock, DeleteFn, SizeFn,
|
|
259
|
-
SaveToFn, CreateFn);
|
|
260
|
+
SaveToFn, CreateFn, &helper1_wos);
|
|
261
|
+
Cache::CacheItemHelper helper2_wos(CacheEntryRole::kIndexBlock, DeleteFn);
|
|
260
262
|
Cache::CacheItemHelper helper2(CacheEntryRole::kIndexBlock, DeleteFn, SizeFn,
|
|
261
|
-
SaveToFn, CreateFn);
|
|
263
|
+
SaveToFn, CreateFn, &helper2_wos);
|
|
264
|
+
Cache::CacheItemHelper helper3_wos(CacheEntryRole::kFilterBlock, DeleteFn);
|
|
262
265
|
Cache::CacheItemHelper helper3(CacheEntryRole::kFilterBlock, DeleteFn, SizeFn,
|
|
263
|
-
SaveToFn, CreateFn);
|
|
266
|
+
SaveToFn, CreateFn, &helper3_wos);
|
|
264
267
|
} // namespace
|
|
265
268
|
|
|
266
269
|
class CacheBench {
|
|
@@ -544,7 +547,7 @@ class CacheBench {
|
|
|
544
547
|
}
|
|
545
548
|
// do lookup
|
|
546
549
|
handle = cache_->Lookup(key, &helper2, /*context*/ nullptr,
|
|
547
|
-
Cache::Priority::LOW
|
|
550
|
+
Cache::Priority::LOW);
|
|
548
551
|
if (handle) {
|
|
549
552
|
if (!FLAGS_lean) {
|
|
550
553
|
// do something with the data
|
|
@@ -573,7 +576,7 @@ class CacheBench {
|
|
|
573
576
|
}
|
|
574
577
|
// do lookup
|
|
575
578
|
handle = cache_->Lookup(key, &helper2, /*context*/ nullptr,
|
|
576
|
-
Cache::Priority::LOW
|
|
579
|
+
Cache::Priority::LOW);
|
|
577
580
|
if (handle) {
|
|
578
581
|
if (!FLAGS_lean) {
|
|
579
582
|
// do something with the data
|
|
@@ -143,7 +143,7 @@ class CacheEntryStatsCollector {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
// If we reach here, shared entry is in cache with handle `h`.
|
|
146
|
-
assert(cache.get()->GetCacheItemHelper(h) ==
|
|
146
|
+
assert(cache.get()->GetCacheItemHelper(h) == cache.GetBasicHelper());
|
|
147
147
|
|
|
148
148
|
// Build an aliasing shared_ptr that keeps `ptr` in cache while there
|
|
149
149
|
// are references.
|
|
@@ -169,7 +169,7 @@ Slice CacheReservationManagerImpl<R>::GetNextCacheKey() {
|
|
|
169
169
|
template <CacheEntryRole R>
|
|
170
170
|
const Cache::CacheItemHelper*
|
|
171
171
|
CacheReservationManagerImpl<R>::TEST_GetCacheItemHelperForRole() {
|
|
172
|
-
return
|
|
172
|
+
return CacheInterface::GetHelper();
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
template class CacheReservationManagerImpl<
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
#include "cache/lru_cache.h"
|
|
19
19
|
#include "cache/typed_cache.h"
|
|
20
20
|
#include "port/stack_trace.h"
|
|
21
|
+
#include "test_util/secondary_cache_test_util.h"
|
|
21
22
|
#include "test_util/testharness.h"
|
|
22
23
|
#include "util/coding.h"
|
|
23
24
|
#include "util/string_util.h"
|
|
@@ -81,13 +82,10 @@ const Cache::CacheItemHelper kEraseOnDeleteHelper2{
|
|
|
81
82
|
Cache* cache = static_cast<Cache*>(value);
|
|
82
83
|
cache->Erase(EncodeKey16Bytes(1234));
|
|
83
84
|
}};
|
|
84
|
-
|
|
85
|
-
const std::string kLRU = "lru";
|
|
86
|
-
const std::string kHyperClock = "hyper_clock";
|
|
87
|
-
|
|
88
85
|
} // anonymous namespace
|
|
89
86
|
|
|
90
|
-
class CacheTest : public testing::
|
|
87
|
+
class CacheTest : public testing::Test,
|
|
88
|
+
public secondary_cache_test_util::WithCacheTypeParam {
|
|
91
89
|
public:
|
|
92
90
|
static CacheTest* current_;
|
|
93
91
|
static std::string type_;
|
|
@@ -95,8 +93,7 @@ class CacheTest : public testing::TestWithParam<std::string> {
|
|
|
95
93
|
static void Deleter(Cache::ObjectPtr v, MemoryAllocator*) {
|
|
96
94
|
current_->deleted_values_.push_back(DecodeValue(v));
|
|
97
95
|
}
|
|
98
|
-
static
|
|
99
|
-
&Deleter};
|
|
96
|
+
static const Cache::CacheItemHelper kHelper;
|
|
100
97
|
|
|
101
98
|
static const int kCacheSize = 1000;
|
|
102
99
|
static const int kNumShardBits = 4;
|
|
@@ -108,8 +105,6 @@ class CacheTest : public testing::TestWithParam<std::string> {
|
|
|
108
105
|
std::shared_ptr<Cache> cache_;
|
|
109
106
|
std::shared_ptr<Cache> cache2_;
|
|
110
107
|
|
|
111
|
-
size_t estimated_value_size_ = 1;
|
|
112
|
-
|
|
113
108
|
CacheTest()
|
|
114
109
|
: cache_(NewCache(kCacheSize, kNumShardBits, false)),
|
|
115
110
|
cache2_(NewCache(kCacheSize2, kNumShardBits2, false)) {
|
|
@@ -119,41 +114,6 @@ class CacheTest : public testing::TestWithParam<std::string> {
|
|
|
119
114
|
|
|
120
115
|
~CacheTest() override {}
|
|
121
116
|
|
|
122
|
-
std::shared_ptr<Cache> NewCache(size_t capacity) {
|
|
123
|
-
auto type = GetParam();
|
|
124
|
-
if (type == kLRU) {
|
|
125
|
-
return NewLRUCache(capacity);
|
|
126
|
-
}
|
|
127
|
-
if (type == kHyperClock) {
|
|
128
|
-
return HyperClockCacheOptions(
|
|
129
|
-
capacity, estimated_value_size_ /*estimated_value_size*/)
|
|
130
|
-
.MakeSharedCache();
|
|
131
|
-
}
|
|
132
|
-
return nullptr;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
std::shared_ptr<Cache> NewCache(
|
|
136
|
-
size_t capacity, int num_shard_bits, bool strict_capacity_limit,
|
|
137
|
-
CacheMetadataChargePolicy charge_policy = kDontChargeCacheMetadata) {
|
|
138
|
-
auto type = GetParam();
|
|
139
|
-
if (type == kLRU) {
|
|
140
|
-
LRUCacheOptions co;
|
|
141
|
-
co.capacity = capacity;
|
|
142
|
-
co.num_shard_bits = num_shard_bits;
|
|
143
|
-
co.strict_capacity_limit = strict_capacity_limit;
|
|
144
|
-
co.high_pri_pool_ratio = 0;
|
|
145
|
-
co.metadata_charge_policy = charge_policy;
|
|
146
|
-
return NewLRUCache(co);
|
|
147
|
-
}
|
|
148
|
-
if (type == kHyperClock) {
|
|
149
|
-
return HyperClockCacheOptions(capacity, 1 /*estimated_value_size*/,
|
|
150
|
-
num_shard_bits, strict_capacity_limit,
|
|
151
|
-
nullptr /*allocator*/, charge_policy)
|
|
152
|
-
.MakeSharedCache();
|
|
153
|
-
}
|
|
154
|
-
return nullptr;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
117
|
// These functions encode/decode keys in tests cases that use
|
|
158
118
|
// int keys.
|
|
159
119
|
// Currently, HyperClockCache requires keys to be 16B long, whereas
|
|
@@ -187,8 +147,8 @@ class CacheTest : public testing::TestWithParam<std::string> {
|
|
|
187
147
|
|
|
188
148
|
void Insert(std::shared_ptr<Cache> cache, int key, int value,
|
|
189
149
|
int charge = 1) {
|
|
190
|
-
EXPECT_OK(
|
|
191
|
-
|
|
150
|
+
EXPECT_OK(cache->Insert(EncodeKey(key), EncodeValue(value), &kHelper,
|
|
151
|
+
charge, /*handle*/ nullptr, Cache::Priority::HIGH));
|
|
192
152
|
}
|
|
193
153
|
|
|
194
154
|
void Erase(std::shared_ptr<Cache> cache, int key) {
|
|
@@ -212,6 +172,9 @@ class CacheTest : public testing::TestWithParam<std::string> {
|
|
|
212
172
|
void Erase2(int key) { Erase(cache2_, key); }
|
|
213
173
|
};
|
|
214
174
|
|
|
175
|
+
const Cache::CacheItemHelper CacheTest::kHelper{CacheEntryRole::kMisc,
|
|
176
|
+
&CacheTest::Deleter};
|
|
177
|
+
|
|
215
178
|
CacheTest* CacheTest::current_;
|
|
216
179
|
std::string CacheTest::type_;
|
|
217
180
|
|
|
@@ -993,8 +956,9 @@ TEST_P(CacheTest, GetChargeAndDeleter) {
|
|
|
993
956
|
}
|
|
994
957
|
|
|
995
958
|
INSTANTIATE_TEST_CASE_P(CacheTestInstance, CacheTest,
|
|
996
|
-
|
|
997
|
-
INSTANTIATE_TEST_CASE_P(CacheTestInstance, LRUCacheTest,
|
|
959
|
+
secondary_cache_test_util::GetTestingCacheTypes());
|
|
960
|
+
INSTANTIATE_TEST_CASE_P(CacheTestInstance, LRUCacheTest,
|
|
961
|
+
testing::Values(secondary_cache_test_util::kLRU));
|
|
998
962
|
|
|
999
963
|
} // namespace ROCKSDB_NAMESPACE
|
|
1000
964
|
|
|
@@ -11,7 +11,7 @@ namespace ROCKSDB_NAMESPACE {
|
|
|
11
11
|
|
|
12
12
|
ChargedCache::ChargedCache(std::shared_ptr<Cache> cache,
|
|
13
13
|
std::shared_ptr<Cache> block_cache)
|
|
14
|
-
:
|
|
14
|
+
: CacheWrapper(cache),
|
|
15
15
|
cache_res_mgr_(std::make_shared<ConcurrentCacheReservationManager>(
|
|
16
16
|
std::make_shared<
|
|
17
17
|
CacheReservationManagerImpl<CacheEntryRole::kBlobCache>>(
|
|
@@ -20,13 +20,13 @@ ChargedCache::ChargedCache(std::shared_ptr<Cache> cache,
|
|
|
20
20
|
Status ChargedCache::Insert(const Slice& key, ObjectPtr obj,
|
|
21
21
|
const CacheItemHelper* helper, size_t charge,
|
|
22
22
|
Handle** handle, Priority priority) {
|
|
23
|
-
Status s =
|
|
23
|
+
Status s = target_->Insert(key, obj, helper, charge, handle, priority);
|
|
24
24
|
if (s.ok()) {
|
|
25
25
|
// Insert may cause the cache entry eviction if the cache is full. So we
|
|
26
26
|
// directly call the reservation manager to update the total memory used
|
|
27
27
|
// in the cache.
|
|
28
28
|
assert(cache_res_mgr_);
|
|
29
|
-
cache_res_mgr_->UpdateCacheReservation(
|
|
29
|
+
cache_res_mgr_->UpdateCacheReservation(target_->GetUsage())
|
|
30
30
|
.PermitUncheckedError();
|
|
31
31
|
}
|
|
32
32
|
return s;
|
|
@@ -35,25 +35,33 @@ Status ChargedCache::Insert(const Slice& key, ObjectPtr obj,
|
|
|
35
35
|
Cache::Handle* ChargedCache::Lookup(const Slice& key,
|
|
36
36
|
const CacheItemHelper* helper,
|
|
37
37
|
CreateContext* create_context,
|
|
38
|
-
Priority priority,
|
|
39
|
-
|
|
40
|
-
auto handle =
|
|
41
|
-
cache_->Lookup(key, helper, create_context, priority, wait, stats);
|
|
38
|
+
Priority priority, Statistics* stats) {
|
|
39
|
+
auto handle = target_->Lookup(key, helper, create_context, priority, stats);
|
|
42
40
|
// Lookup may promote the KV pair from the secondary cache to the primary
|
|
43
41
|
// cache. So we directly call the reservation manager to update the total
|
|
44
42
|
// memory used in the cache.
|
|
45
43
|
if (helper && helper->create_cb) {
|
|
46
44
|
assert(cache_res_mgr_);
|
|
47
|
-
cache_res_mgr_->UpdateCacheReservation(
|
|
45
|
+
cache_res_mgr_->UpdateCacheReservation(target_->GetUsage())
|
|
48
46
|
.PermitUncheckedError();
|
|
49
47
|
}
|
|
50
48
|
return handle;
|
|
51
49
|
}
|
|
52
50
|
|
|
51
|
+
void ChargedCache::WaitAll(AsyncLookupHandle* async_handles, size_t count) {
|
|
52
|
+
target_->WaitAll(async_handles, count);
|
|
53
|
+
// In case of any promotions. Although some could finish by return of
|
|
54
|
+
// StartAsyncLookup, Wait/WaitAll will generally be used, so simpler to
|
|
55
|
+
// update here.
|
|
56
|
+
assert(cache_res_mgr_);
|
|
57
|
+
cache_res_mgr_->UpdateCacheReservation(target_->GetUsage())
|
|
58
|
+
.PermitUncheckedError();
|
|
59
|
+
}
|
|
60
|
+
|
|
53
61
|
bool ChargedCache::Release(Cache::Handle* handle, bool useful,
|
|
54
62
|
bool erase_if_last_ref) {
|
|
55
|
-
size_t memory_used_delta =
|
|
56
|
-
bool erased =
|
|
63
|
+
size_t memory_used_delta = target_->GetUsage(handle);
|
|
64
|
+
bool erased = target_->Release(handle, useful, erase_if_last_ref);
|
|
57
65
|
if (erased) {
|
|
58
66
|
assert(cache_res_mgr_);
|
|
59
67
|
cache_res_mgr_
|
|
@@ -64,8 +72,8 @@ bool ChargedCache::Release(Cache::Handle* handle, bool useful,
|
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
bool ChargedCache::Release(Cache::Handle* handle, bool erase_if_last_ref) {
|
|
67
|
-
size_t memory_used_delta =
|
|
68
|
-
bool erased =
|
|
75
|
+
size_t memory_used_delta = target_->GetUsage(handle);
|
|
76
|
+
bool erased = target_->Release(handle, erase_if_last_ref);
|
|
69
77
|
if (erased) {
|
|
70
78
|
assert(cache_res_mgr_);
|
|
71
79
|
cache_res_mgr_
|
|
@@ -76,25 +84,25 @@ bool ChargedCache::Release(Cache::Handle* handle, bool erase_if_last_ref) {
|
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
void ChargedCache::Erase(const Slice& key) {
|
|
79
|
-
|
|
87
|
+
target_->Erase(key);
|
|
80
88
|
assert(cache_res_mgr_);
|
|
81
|
-
cache_res_mgr_->UpdateCacheReservation(
|
|
89
|
+
cache_res_mgr_->UpdateCacheReservation(target_->GetUsage())
|
|
82
90
|
.PermitUncheckedError();
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
void ChargedCache::EraseUnRefEntries() {
|
|
86
|
-
|
|
94
|
+
target_->EraseUnRefEntries();
|
|
87
95
|
assert(cache_res_mgr_);
|
|
88
|
-
cache_res_mgr_->UpdateCacheReservation(
|
|
96
|
+
cache_res_mgr_->UpdateCacheReservation(target_->GetUsage())
|
|
89
97
|
.PermitUncheckedError();
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
void ChargedCache::SetCapacity(size_t capacity) {
|
|
93
|
-
|
|
101
|
+
target_->SetCapacity(capacity);
|
|
94
102
|
// SetCapacity can result in evictions when the cache capacity is decreased,
|
|
95
103
|
// so we would want to update the cache reservation here as well.
|
|
96
104
|
assert(cache_res_mgr_);
|
|
97
|
-
cache_res_mgr_->UpdateCacheReservation(
|
|
105
|
+
cache_res_mgr_->UpdateCacheReservation(target_->GetUsage())
|
|
98
106
|
.PermitUncheckedError();
|
|
99
107
|
}
|
|
100
108
|
|