feat(memory): apply kernel memory tunables before memory-mode runs - #507
Draft
not-matthias wants to merge 3 commits into
Draft
feat(memory): apply kernel memory tunables before memory-mode runs#507not-matthias wants to merge 3 commits into
not-matthias wants to merge 3 commits into
Conversation
The sysctl read-then-write-with-sudo primitive is not walltime-specific; memory mode needs it too.
Tri-state (auto|on|off, CODSPEED_MEMORY_TUNABLES) controlling whether the runner stabilises kernel memory behaviour before memory-mode runs.
Disables transparent huge pages, sets vm.compaction_proactiveness, vm.swappiness and kernel.numa_balancing to 0, disables swap and drops the page cache, so benchmark repos no longer need a hand-written CI step. Applied only in CI by default, best-effort: a knob that cannot be set is a warning. swapoff is skipped on zram devices and whenever the swapped pages would not fit in available memory.
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.
Benchmark repos running
codspeed --mode memorycurrently need a hand-written CI step to stabilise kernel memory behaviour before measuring: disable THP, zerovm.compaction_proactiveness/vm.swappiness/kernel.numa_balancing,swapoff -a, and drop the page cache before each suite.The runner now does this itself at the start of every memory-mode execution.
Behaviour
--memory-tunables auto|on|off(envCODSPEED_MEMORY_TUNABLES), defaultauto= apply only when a CI run environment is detected, so developer machines are not silently mutated.swapoff -ais guarded: skipped on zram devices (it permanently resets theirdisksize) and whenever the swapped pages would not fit inMemAvailable.run()rather thansetup(), so the page cache is dropped before every suite and--skip-setupdoes not bypass it. The sysctl/THP writes are no-ops on later suites sinceensure_sysctlcompares before writing.Commits
refactor(executor): move linux_sysctl into executor helpers— pure move, the sysctl primitive is no longer walltime-specific.feat(cli): add --memory-tunables flagfeat(memory): apply kernel memory tunables before memory-mode runsVerification
cargo clippy --all-targetsclean,cargo test --release(pre-existing failures on this host are the sudo-requiring tests, identical onmain).Not running in CI, skipping kernel memory tunables; host THP unchanged.--memory-tunables=on: THPenabled/defragbecome[never],vm.compaction_proactiveness = 0,vm.swappiness = 0, and the swap guard correctly loggedLeaving swap enabled: swapped pages do not fit in available memory.