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 committed Jul 5, 2023
1 parent 81b42e6 commit 7ba8684
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/kv/kvserver/store.go
Expand Up @@ -93,10 +93,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 All @@ -123,6 +119,14 @@ var storeSchedulerConcurrency = envutil.EnvOrDefaultInt(
// As of November 2020, this default value could be re-tuned.
"COCKROACH_SCHEDULER_CONCURRENCY", min(8*runtime.GOMAXPROCS(0), 96))

// 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 @@ -1182,7 +1186,7 @@ func (sc *StoreConfig) SetDefaults() {
sc.CoalescedHeartbeatsInterval = sc.RaftTickInterval / 2
}
if sc.RaftEntryCacheSize == 0 {
sc.RaftEntryCacheSize = defaultRaftEntryCacheSize
sc.RaftEntryCacheSize = uint64(defaultRaftEntryCacheSize)
}

if sc.TestingKnobs.GossipWhenCapacityDeltaExceedsFraction == 0 {
Expand Down

0 comments on commit 7ba8684

Please sign in to comment.