Skip to content

go/store/prolly/tree: Add DOLT_NODE_CACHE_SIZE env var for prolly node cache - #10815

Closed
stebbins wants to merge 1 commit into
dolthub:mainfrom
skullbloc:do-ni4-node-cache-size
Closed

stebbins wants to merge 1 commit into
dolthub:mainfrom
skullbloc:do-ni4-node-cache-size

Conversation

@stebbins

@stebbins stebbins commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

The prolly tree node cache is hardcoded at 256 MiB and is the dominant memory consumer in Dolt. This makes it configurable via the DOLT_NODE_CACHE_SIZE environment variable, following the exact same pattern as the existing DOLT_COMMIT_CACHE_SIZE env var.

For memory-constrained deployments (containers, small VMs), setting DOLT_NODE_CACHE_SIZE=33554432 (32 MiB) significantly reduces RSS with minimal performance impact for small datasets.

No default behavior change — without the env var, cache remains 256 MiB.

  • go/store/prolly/tree/node_store.go — const cacheSize changed to var, init() reads env var
  • go/libraries/doltcore/dconfig/envvars.go — EnvNodeCacheSize constant
  • go/store/prolly/tree/node_cache_test.go — tests for valid, invalid, zero, and negative values

@stebbins stebbins changed the title Add DOLT_NODE_CACHE_SIZE environment variable for prolly node cache go/store/prolly/tree: Add DOLT_NODE_CACHE_SIZE env var for prolly node cache Apr 4, 2026
@stebbins
stebbins force-pushed the do-ni4-node-cache-size branch from 78f710b to c2a0e14 Compare April 4, 2026 16:40

@reltuk reltuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little skeptical of making this configurable from an environment variable. I know we did a similar thing with commit cache, but that was because we were going from small -> large for a particular use case and we wanted to build an escape hatch if we critically regressed anyone.

In general the node cache and the sizecache on ValueStore are a pretty big wart, not least of all because they aren't configurable on a per-server or per-database level, as you've rightly pointed out here here with this PR.

We are certainly interested in making Dolt work better in low memory environments and we are ammenable to changes which move us in that direction. I worry that these specific env variables might be too tightly coupled to the existing caches and discovering and appropriately setting them is an experts task which we have little bandwidth to support in general.

What do you think about a different approach where we do one of the following:

  1. Gracefully scale these caches from some minimum size to their existing defaults based on existing configured GOMEMLIMITs. Pairs nicely with #10813.
  2. Bimodally choose between some small limit and the existing default based on GOMEMLIMIT.
  3. Have a generic boolean-optioned env var which configures smaller defaults for these and potentially other caches in the future. DOLT_LOWMEM=, for example.
  4. Like 3, but that variable is enum-valued or float-valued. Float-valued selects a point on a linear scale from min-to-max for these and other similar sized caches. enum-valued picks fixed sizes at each point for various classes of requested constrained memory utilization.

@stebbins

stebbins commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

@reltuk thanks for taking a look! I think I'll close these env var PRs in favor of this approach based on your feedback: #10820

what do you think? it should scale gracefully based on GOMEMLIMIT, based on the ratios that were already implemented.

additional configuration probably makes sense for followup, but maybe it makes sense to just give a tuner where you can set the ratio of reserved memory to favor node cache for reads and memtable for writes?

@stebbins

stebbins commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

#10815 (comment)

closing in favor of #10820

@stebbins stebbins closed this Apr 7, 2026
@stebbins

stebbins commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

#10821

to make it easier since there are already a few PRs, i created an issue to track the concept

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants