Skip to content

perf(compaction): drop compaction I/O from page cache via FADV_DONTNEED - #215

Merged
ovaistariq merged 2 commits into
mainfrom
perf/compaction-page-cache-advice
Aug 17, 2026
Merged

ovaistariq merged 2 commits into
mainfrom
perf/compaction-page-cache-advice

Conversation

@ovaistariq

@ovaistariq ovaistariq commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Compaction reads one-pass raw-file/segment inputs and writes segment outputs through the page cache, evicting warm serving data. Track written output ranges per segment and drop them (plus one-pass input pages) with posix_fadvise(FADV_DONTNEED) only after the segment is synced; no-op on non-Linux. Also adds the missing newSeg.Sync() before recompaction metadata publish.

Candidate cand_g41znje23g from perfloop case_61m5ctxv01, validated locally (memory-limited Linux containers, mincore-based residency).


Note

Cursor Bugbot is generating a summary for commit 97c8ebf. Configure here.

efirs
efirs previously approved these changes Aug 17, 2026
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown

Greptile Summary

The PR reduces compaction page-cache pollution on Linux by advising the kernel to discard one-pass input pages and synced output ranges, while retaining no-op behavior on other platforms. It also syncs recompaction output before publishing its metadata.

  • Adds platform-specific FADV_DONTNEED support and per-segment output-range tracking.
  • Integrates cache advice with file compaction, segment rotation, and recompaction.
  • Expands correctness tests and adds Linux page-residency serving benchmarks.

Confidence Score: 5/5

The PR appears safe to merge, with cache eviction ordered after durable output synchronization and no concrete correctness or security defect identified.

The changed compaction paths preserve metadata and segment ordering, use stable segment identities for range tracking, and treat cache advice as a guarded best-effort optimization.

Important Files Changed

Filename Overview
storage/compaction/cache_advice.go Tracks and merges output ranges by stable segment identity, removing each range after its one-time cache-drop operation.
storage/compaction/cache_advice_linux.go Implements guarded, best-effort Linux cache eviction through FADV_DONTNEED.
storage/compaction/compactor.go Drops raw-file input pages after copying and output pages only after segment synchronization or finalization.
storage/compaction/recompactor.go Adds input/output cache advice and ensures copied segment data is synced before metadata publication.
storage/compaction_serving_bench_linux_test.go Adds Linux-only benchmarks and validated page-residency helpers for measuring compaction effects on serving workloads.

Reviews (1): Last reviewed commit: "perf(compaction): drop compaction I/O fr..." | Re-trigger Greptile

ovaistariq and others added 2 commits August 17, 2026 11:23
Compaction reads one-pass raw-file/segment inputs and writes segment
outputs through the page cache, evicting warm serving data. Track
written output ranges per segment and drop them (plus one-pass input
pages) with posix_fadvise(FADV_DONTNEED) only after the segment is
synced; no-op on non-Linux. Also adds the missing newSeg.Sync() before
recompaction metadata publish.

Candidate cand_g41znje23g from perfloop case_61m5ctxv01, validated
locally (memory-limited Linux containers, mincore-based residency).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L5DLvDTo9dhD38YQXhHpU9
Signed-off-by: Ovais Tariq <[email protected]>
@ovaistariq
ovaistariq force-pushed the perf/compaction-page-cache-advice branch from 18798d0 to 3a4eb21 Compare August 17, 2026 18:23
@ovaistariq
ovaistariq merged commit 99e3f52 into main Aug 17, 2026
10 checks passed
@ovaistariq
ovaistariq deleted the perf/compaction-page-cache-advice branch August 17, 2026 19:21
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.10.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants