Pool recycling of pageout'd regions: validate syscall costs and residency semantics

Abierto
#1 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
linux, rust

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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:

  1. Drop routes through ThreadLocalStealer::deallocate → worker queue.
  2. 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).
  3. MADV_FREE on 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_PAGEOUT cost: pageout a resident region, re-write it. Measure fault cost and whether THP is still in effect (/proc/self/smaps → AnonHugePages).
  • Post-MADV_COLD cost: same, but just marking cold. Does re-touch rebuild THP?
  • Post-MADV_DONTNEED cost: 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 / mincore per 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

  1. Every dealloc runs MADV_DONTNEED on 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.
  2. MADV_DONTNEED only 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.
  3. mincore-gated decision. Call mincore first; only MADV_DONTNEED if a significant fraction of the region is non-resident (heuristic: user recently pageout'd). Adds a syscall but may be cheaper than unconditional MADV_DONTNEED on huge regions.
  4. 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_DONTNEED reliably 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.

Lenguaje dominante
Rust
Estrellas
0
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.