Repository navigation
perf(memory): take the cache load off startup and session hooks - #28
Merged
Merged
Conversation
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.
What does this PR do?
Takes the memory cache load off the startup path and off the session hooks.
auto-capture,checkpointandclose-sessionread their context from the database and do not load the whole bank.This does not make the first memory call faster. It still needs the full cache, so on a starved machine memory tools return
startingfor minutes.Behavior changes
startingerror./healthaddsmemory_ready.memory_availablenow means the store is open.Why?
Loading the cache costs about 0.9 s of CPU and 679 MB of allocations on a 33,580-record bank. Every server start and every hook paid for it, and rebuilds after a foreign write held the store locks.
Measurements
Real binary on a copy of the bank, before → after. The 2% CPU column limits only the measured process.
checkpoint, largest contextcheckpoint, second contextPeak memory of
checkpointfell from 371–393 MB to 200–210 MB in the largest context, and from 371–405 MB to 33–36 MB in the second.Machine load varied between runs: unthrottled
checkpointran at load about 5 before and about 16 after. At 2% CPU,checkpointran once per binary and MCP twice.Testing
gofmt,make vetandgo test -race ./...pass.Closeduring a load.NewStore. Only 4 tests failed, all of which assert on an already loaded cache or on thecache_loadstartup log line.Not verified