Select mmap madvise by index type: MADV_RANDOM for DiskSeismic, not a global hugepage default - #55
Merged
chishui merged 1 commit intoSep 14, 2026
Conversation
…ion based on index type Signed-off-by: Zirui Song <zrsong@amazon.com>
zirui-song-18
requested review from
chishui,
model-collapse and
yuye-aws
as code owners
September 14, 2026 03:27
Collaborator
|
the PR looks good to me, but before approval, it's better to root cause the reason of degradation first |
Collaborator
|
discussed offline, this is a bug not a degradation and it impacts disk seismic's index performance when memory is not enough |
chishui
reviewed
Sep 14, 2026
| } | ||
|
|
||
| const char* advise = std::getenv("NSPARSE_MMAP_ADVISE"); | ||
| std::string mode = (advise != nullptr) ? advise : "hugepage"; |
Collaborator
There was a problem hiding this comment.
previous logic is: for all indices, no madvise is called, now you change to only set disk seismic index to random
chishui
approved these changes
Sep 14, 2026
1 of 5 tasks
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.
Description
What
MmapFileapplied one globalmadvisedefault —MADV_HUGEPAGE— to every index type. That is right for thesharedSeismic indexes (queries scan broad regions of one forward index), but wrong for DiskSeismic /per_block, whose whole design is to point-read only ~k′ small (~8 KiB) inline-forward blocks per query. Hugepage (2 MiB fault granularity) plus RAID readahead turns each of those tiny reads into a huge one.This makes the madvise hint a function of the index's access pattern instead of a single global default:
DiskSeismicIndex,DiskSeismicScalarQuantizedIndex) →MADV_RANDOM(point lookups; suppress readahead).shared(SeismicIndex,SeismicScalarQuantizedIndex) →MADV_HUGEPAGE(broad scans; fewer TLB entries), unchanged.NSPARSE_MMAP_ADVISEstill overrides the choice (an empty value is treated as unset, so it can't silently reinstate the old default).Measured impact
From the launch benchmark (i4i.16xlarge, MS MARCO V1, 12 GB page-cache cap, THP=
[madvise], top_n=5, k′=20, recall ≈ 0.92), same index and queries:per_block)per_block)Implementation notes
MmapFile::resolve_advise) that is unit-tested, and DiskSeismic types map their file through one base-class entry point (DiskSeismicIndexBase::map_index_file) so a future disk index type can't silently fall back to the scan/hugepage default.Testing
strace: a DiskSeismic serialized-index mapping issuesMADV_RANDOM, asharedmapping issuesMADV_HUGEPAGE.Issues Resolved
List any issues this PR will resolve, e.g. Closes [...].
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.