Default Cache Size

With PR #18040 the default cache size will change from 25% of physical memory to 128MiB. If you’re running CockroachDB in a production environment you’ll likely want to explicitly specify --cache=25% (or a larger value) for improved read performance. Note that this applies to the 1.1 release of Cockroach (which hasn’t been released yet), not 1.0.

From the PR:

Previously, these settings defaulted to 1/4 of physical memory. That is
a reasonable default for production, but not for development or an
environment where cockroach is sharing resources with other processes on
the machine. For example, it was previously very easy to run a 5-node
cluster locally on a single machine and have each cockroach node
configured to use 1/4 of physical memory for cache. Leave it running too
long and the cluster will crash.

Using a relatively small cache size by default also avoids the perceived
memory leak where cockroach will grow to fill the cache even when idle
due to the writing of timeseries data.

#18040 includes a warning printed at startup to indicate that the default cache size is being used. We’ll likely a warning to the admin UI in a follow-on PR.

The value of 128MiB is somewhat arbitrary, but in line with the defaults used by PostgreSQL (128MiB) and MySQL (128MiB).

If I have a server which has no purpose except to run cockroachdb, what value should I set the cache size to?

From what I’ve read, this cache size doesn’t cover all cockroachdb memory usage, so I can’t just set it to 100% can I?

(Looking at the PR, there is also --max-sql-memory)

@pooper Correct, the cache size does not cover all of the memory usage of CockroachDB. The are various other smaller caches, and of course, there needs to be some memory for the OS and the executable itself. Over time we’d like to move towards having a single knob which controls the total memory usage of CockroachDB but we’re not there yet. The non-RocksDB cache memory usage is in the 300-500MiB range. A value of --cache=50% is likely fairly safe. If your system still has free memory you can try increasing the value, though you almost certainly want to leave a little slack.