Pool recycling of pageout'd regions: validate syscall costs and residency semantics
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- linux, rust
- Domain
- operating-systems, performance
Research direction
Start at ThreadLocalStealer::deallocate and run the listed experiments across the representative allocation sizes, measuring first-touch time, mincore residency, AnonHugePages in /proc/self/smaps, and syscall overhead for each advisory. Done means comparing the four mitigation proposals on Linux 5.15+ and recording whether the data supports a runtime change or documentation-only approach.
Written by the indexing model from the issue text.
Description
Context
When a user allocates a region, writes to it, calls pageout (MADV_PAGEOUT), and then deallocates, the pool recycles the (now-cold) allocation. The next caller that writes to the recycled region pays page-fault cost on first access. The pool's implicit contract ("cheap to re-hand-out") is violated silently.
Current deallocation path:
- Drop routes through
ThreadLocalStealer::deallocate→ worker queue. - Eventually either handed out again, or moved to the global injector and later cleared by the background worker via
MADV_FREE(Linux) /MADV_DONTNEED(other). MADV_FREEon pageout'd pages is a no-op — the pages are already gone.
Pages can also lose THP backing silently. MADV_COLD / MADV_PAGEOUT may split a transparent huge page to operate on a sub-range; splits are not automatically reversed.
Experiments to run
Measure, in isolation, with representative allocation sizes (2 MiB, 16 MiB, 128 MiB, 1 GiB):
- Baseline write cost on a freshly-mmaped anonymous region with
MADV_HUGEPAGE: first-touch fault cost, bandwidth for full write-through. - Post-
MADV_PAGEOUTcost: pageout a resident region, re-write it. Measure fault cost and whether THP is still in effect (/proc/self/smaps→AnonHugePages). - Post-
MADV_COLDcost: same, but just marking cold. Does re-touch rebuild THP? - Post-
MADV_DONTNEEDcost: does the kernel re-fault into huge pages, or small pages? - Post-
MADV_FREE(then reclaimed) cost: pressure the kernel into reclaiming, then re-touch. - Syscall overhead of
MADV_DONTNEED/MADV_FREE/mincoreper call, as a function of region size.
Track per-scenario:
- Time to first-touch the region after the advisory.
- Residency after re-touch (via
mincore). - Huge-page status after re-touch.
Mitigation proposals to compare
- Every dealloc runs
MADV_DONTNEEDon the region before it re-enters the pool. Guarantees the next caller faults into fresh (presumably THP-backed) pages. Costs one syscall per dealloc.- Open question: after
MADV_DONTNEED, does the next touch fault into a huge page, or small pages? Empirically the kernel has flip-flopped on this across versions.
- Open question: after
MADV_DONTNEEDonly on promotion to the global injector. Thread-local reuse skips it (fast path for allocate-then-dealloc-then-allocate within one thread). Cross-thread handoffs pay the cost.mincore-gated decision. Callmincorefirst; onlyMADV_DONTNEEDif a significant fraction of the region is non-resident (heuristic: user recently pageout'd). Adds a syscall but may be cheaper than unconditionalMADV_DONTNEEDon huge regions.- Status quo + documentation.
pageout's doc warns callers that deallocating a pageout'd region hands cold memory to the next caller. No runtime mitigation.
Decision inputs
- Absolute syscall cost vs. absolute page-fault cost at representative sizes.
- Whether
MADV_DONTNEEDreliably rebuilds THP on re-touch under current kernels (5.15+ target). - Whether
mincore's cost scales acceptably for our size classes (up to 128 GiB).
Scope
Investigation only for 0.1.x. If experiments point to a clear winner, ship the mitigation in a minor release. Until then, rely on the (yet-to-add) doc warning on pageout.
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
Android bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anefzaoui/misterdownloadmanager#2516 ·
Maintainers usually reply within 1 day
-
editor ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
state:triage tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 89/100
agent8-cash/ethpayserver#731 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day