Repository navigation
Size the node cache in megabytes - #69
Merged
Merged
Conversation
The cache limit was a number of decoded nodes, which says little about memory: a node can be a few bytes or a full page. Each shard now has a byte budget and every node counts as the size of its page, header plus payload when read and the image size when written. CLOCK eviction is kept, on a linked ring so entries can differ in size. The cache_nodes setting becomes cache_mb, 256 by default.
…che_mb Whether it comes from hstore.conf, an HSTORE_CACHE_NODES variable or a flag, startup now stops with a message saying to use cache_mb, instead of failing on an unknown key or quietly ignoring it.
venkat1701
force-pushed
the
feat/cache-mb
branch
from
October 6, 2026 01:37
ca26be1 to
5f5a9dc
Compare
This was referenced Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #59
Stacked on #66 (which is stacked on #65), because the benchmark adapter changes in all three. Merge those first; then this PR's base needs switching to
main.The cache limit was a count of decoded nodes, so it said little about memory: a node can be a few bytes or a full 16 KiB page. As agreed:
cache_mb(HSTORE_CACHE_MB), default 256. The old default of 65,536 nodes could reach 1 GiB, so this is smaller in the worst case. Easy to change if you want a different default.cache_nodesis removed. If it's set inhstore.conf, asHSTORE_CACHE_NODESor as--cache-nodes, the server refuses to start (exit code 2) with: cache_nodes is no longer supported: the node cache is now sized in megabytes. Remove cache_nodes and set cache_mb instead. Before this, the variable and the flag would have been silently ignored.How the cache changed: each of the 16 shards now has a byte budget (at least 64 KiB). Eviction is still CLOCK (second chance), but on a circular linked ring instead of a fixed array, so entries can differ in size. New entries go just behind the hand, so they get a full sweep before they can be evicted. A node bigger than a shard's whole budget isn't cached.
Also: Studio's
/api/statsreportscacheBytesinstead ofcachedNodes, and the dashboard shows the cache in bytes. The benchmark keeps its effectively unlimited default (16 GiB, the same ceiling as the old 1M nodes), andCACHE_MBis now passed straight through instead of being divided by the page size.Tested:
NodeCacheTest:ServerTest:cache_mbis parsed, the default is 256 MiB, andcache_nodesis refused from the file, the environment and a flag./mvnw installpasses (97 tests); each commit compiles on its own, including the benchmarks modulehstore configshowscache_mb; all three ways of settingcache_nodesgive the message above, with exit code 2--cache_mb 64:/api/statsreports 67,108,864HSTORE_CACHE_MB=128(stats report 134,217,728), clean shutdown, andHSTORE_CACHE_NODESstops it with the messageUnrelated thing I noticed while testing: in JVM mode (
java -m io.hstore.server), SIGTERM ends the process with code 143 before "shut down cleanly" is logged.maindoes the same, and the native image shuts down cleanly. I'll open a separate issue for it.