Skip to content

Commit d2744d2

Browse files
Manuel Unginikep
authored andcommitted
Replace ClockCache with HyperClockCache
Upstream commit ID: facebook/mysql-5.6@09710df PS-8755: Merge percona-202301 (https://jira.percona.com/browse/PS-8755) Summary: This replaces the existing code that enables ClockCache with code that enables HyperClockCache. This is expected to solve block cache contention issues that we've been seeing, making supporting MRR for more scenarios lower priority for us. Reviewed By: pdillinger Differential Revision: D41384156 fbshipit-source-id: f72558deae7161283218fbc4e2263f177adec4f2
1 parent 7526df9 commit d2744d2

File tree

4 files changed

+62
-4
lines changed

4 files changed

+62
-4
lines changed

mysql-test/suite/rocksdb/r/rocksdb.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,7 @@ rocksdb_use_default_sk_cf OFF
10551055
rocksdb_use_direct_io_for_flush_and_compaction OFF
10561056
rocksdb_use_direct_reads OFF
10571057
rocksdb_use_fsync OFF
1058+
rocksdb_use_hyper_clock_cache OFF
10581059
rocksdb_use_write_buffer_manager OFF
10591060
rocksdb_validate_tables 1
10601061
rocksdb_verify_row_debug_checksums OFF
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
2+
INSERT INTO valid_values VALUES(1);
3+
INSERT INTO valid_values VALUES(0);
4+
INSERT INTO valid_values VALUES('on');
5+
INSERT INTO valid_values VALUES('off');
6+
INSERT INTO valid_values VALUES('true');
7+
INSERT INTO valid_values VALUES('false');
8+
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
9+
INSERT INTO invalid_values VALUES('\'aaa\'');
10+
INSERT INTO invalid_values VALUES('\'bbb\'');
11+
SET @start_global_value = @@global.ROCKSDB_USE_HYPER_CLOCK_CACHE;
12+
SELECT @start_global_value;
13+
@start_global_value
14+
0
15+
"Trying to set variable @@global.ROCKSDB_USE_HYPER_CLOCK_CACHE to 444. It should fail because it is readonly."
16+
SET @@global.ROCKSDB_USE_HYPER_CLOCK_CACHE = 444;
17+
ERROR HY000: Variable 'rocksdb_use_hyper_clock_cache' is a read only variable
18+
DROP TABLE valid_values;
19+
DROP TABLE invalid_values;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--source include/have_rocksdb.inc
2+
3+
CREATE TABLE valid_values (value varchar(255)) ENGINE=myisam;
4+
INSERT INTO valid_values VALUES(1);
5+
INSERT INTO valid_values VALUES(0);
6+
INSERT INTO valid_values VALUES('on');
7+
INSERT INTO valid_values VALUES('off');
8+
INSERT INTO valid_values VALUES('true');
9+
INSERT INTO valid_values VALUES('false');
10+
11+
CREATE TABLE invalid_values (value varchar(255)) ENGINE=myisam;
12+
INSERT INTO invalid_values VALUES('\'aaa\'');
13+
INSERT INTO invalid_values VALUES('\'bbb\'');
14+
15+
--let $sys_var=ROCKSDB_USE_HYPER_CLOCK_CACHE
16+
--let $read_only=1
17+
--let $session=0
18+
--source ../include/rocksdb_sys_var.inc
19+
20+
DROP TABLE valid_values;
21+
DROP TABLE invalid_values;

storage/rocksdb/ha_rocksdb.cc

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ static const constexpr uint64_t RDB_DEFAULT_MAX_COMPACTION_HISTORY = 64;
655655

656656
static long long rocksdb_block_cache_size = RDB_DEFAULT_BLOCK_CACHE_SIZE;
657657
static long long rocksdb_sim_cache_size = 0;
658+
static bool rocksdb_use_hyper_clock_cache = false;
658659
static bool rocksdb_charge_memory = false;
659660
static bool rocksdb_use_write_buffer_manager = false;
660661
static double rocksdb_cache_high_pri_pool_ratio = 0.0;
@@ -1844,6 +1845,12 @@ static MYSQL_SYSVAR_LONGLONG(sim_cache_size, rocksdb_sim_cache_size,
18441845
/* max */ LLONG_MAX,
18451846
/* Block size */ 0);
18461847

1848+
static MYSQL_SYSVAR_BOOL(
1849+
use_hyper_clock_cache, rocksdb_use_hyper_clock_cache,
1850+
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
1851+
"Use HyperClockCache instead of default LRUCache for RocksDB", nullptr,
1852+
nullptr, false);
1853+
18471854
static MYSQL_SYSVAR_BOOL(cache_dump, rocksdb_cache_dump,
18481855
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
18491856
"Include RocksDB block cache content in core dump.",
@@ -2584,6 +2591,7 @@ static struct SYS_VAR *rocksdb_system_variables[] = {
25842591

25852592
MYSQL_SYSVAR(block_cache_size),
25862593
MYSQL_SYSVAR(sim_cache_size),
2594+
MYSQL_SYSVAR(use_hyper_clock_cache),
25872595
MYSQL_SYSVAR(cache_high_pri_pool_ratio),
25882596
MYSQL_SYSVAR(cache_dump),
25892597
MYSQL_SYSVAR(cache_index_and_filter_blocks),
@@ -6354,10 +6362,19 @@ static int rocksdb_init_internal(void *const p) {
63546362
"Ignoring rocksdb_cache_dump because jemalloc is missing.");
63556363
#endif // HAVE_JEMALLOC
63566364
}
6357-
std::shared_ptr<rocksdb::Cache> block_cache = rocksdb::NewLRUCache(
6358-
rocksdb_block_cache_size, -1 /*num_shard_bits*/,
6359-
false /*strict_capcity_limit*/, rocksdb_cache_high_pri_pool_ratio,
6360-
memory_allocator);
6365+
std::shared_ptr<rocksdb::Cache> block_cache =
6366+
rocksdb_use_hyper_clock_cache
6367+
? rocksdb::HyperClockCacheOptions(
6368+
rocksdb_block_cache_size, rocksdb_tbl_options->block_size,
6369+
-1
6370+
/* num_shard_bits */,
6371+
false /* strict_capacity_limit */, memory_allocator)
6372+
.MakeSharedCache()
6373+
6374+
: rocksdb::NewLRUCache(
6375+
rocksdb_block_cache_size, -1 /*num_shard_bits*/,
6376+
false /*strict_capcity_limit*/,
6377+
rocksdb_cache_high_pri_pool_ratio, memory_allocator);
63616378
if (rocksdb_sim_cache_size > 0) {
63626379
// Simulated cache enabled
63636380
// Wrap block cache inside a simulated cache and pass it to RocksDB

0 commit comments

Comments
 (0)