Skip to content

Commit

Permalink
kv: expose env var to configure raft entry cache size
Browse files Browse the repository at this point in the history
Informs cockroachdb#98666.

This commit introduces a new `COCKROACH_RAFT_ENTRY_CACHE_SIZE` which can
be used to configure the size of the raft entry cache. The default value
is 16 MiB.

Release note: None
  • Loading branch information
nvanbenschoten authored and jbowens committed Jul 11, 2023
1 parent 72556c6 commit e0ee7cc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/kv/kvserver/store.go
Expand Up @@ -101,10 +101,6 @@ const (
// rangeIDAllocCount is the number of Range IDs to allocate per allocation.
rangeIDAllocCount = 10

// defaultRaftEntryCacheSize is the default size in bytes for a
// store's Raft log entry cache.
defaultRaftEntryCacheSize = 1 << 24 // 16M

// replicaQueueExtraSize is the number of requests that a replica's incoming
// message queue can keep over RaftConfig.RaftMaxInflightMsgs. When the leader
// maxes out RaftMaxInflightMsgs, we want the receiving replica to still have
Expand Down Expand Up @@ -134,6 +130,14 @@ var defaultRaftSchedulerConcurrency = envutil.EnvOrDefaultInt(
// counts, while also avoiding starvation by excessive sharding.
var defaultRaftSchedulerShardSize = envutil.EnvOrDefaultInt("COCKROACH_SCHEDULER_SHARD_SIZE", 16)

// defaultRaftEntryCacheSize is the default size in bytes for a store's Raft
// entry cache. The Raft entry cache is shared by all Raft groups managed by the
// store. It is used to cache uncommitted raft log entries such that once those
// entries are committed, their application can avoid disk reads to retrieve
// them from the persistent log.
var defaultRaftEntryCacheSize = envutil.EnvOrDefaultBytes(
"COCKROACH_RAFT_ENTRY_CACHE_SIZE", 16<<20 /* 16 MiB */)

var logSSTInfoTicks = envutil.EnvOrDefaultInt(
"COCKROACH_LOG_SST_INFO_TICKS_INTERVAL", 60)

Expand Down Expand Up @@ -1203,7 +1207,7 @@ func (sc *StoreConfig) SetDefaults(numStores int) {
sc.RaftSchedulerShardSize = defaultRaftSchedulerShardSize
}
if sc.RaftEntryCacheSize == 0 {
sc.RaftEntryCacheSize = defaultRaftEntryCacheSize
sc.RaftEntryCacheSize = uint64(defaultRaftEntryCacheSize)
}
if envutil.EnvOrDefaultBool("COCKROACH_DISABLE_LEADER_FOLLOWS_LEASEHOLDER", false) {
sc.TestingKnobs.DisableLeaderFollowsLeaseholder = true
Expand Down

0 comments on commit e0ee7cc

Please sign in to comment.