Skip to content

Skip longest_free_range maintenance on dense PageTracker alloc/free. - #1986

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1034676187
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1034676187

Conversation

@copybara-service

Copy link
Copy Markdown

Skip longest_free_range maintenance on dense PageTracker alloc/free.

Dense hugepages in HugePageFiller only serve 1-page spans and index trackers strictly by nallocs() rather than longest_free_range(), yet PageTracker::Get and PageTracker::Put still scan the full 256-bit RangeTracker bitmap on every allocation and deallocation under pageheap_lock to maintain longest_free_.

Parameterize RangeTracker::FindAndMark, Mark, and Unmark with LongestFreeMode (kEager vs kLazy) so dense PageTracker operations locate or flip a single bit with FindClear(0) without updating longest_free_, and compute longest_free_range() lazily via ComputeLongestFree() only for cold telemetry readers (stats printing, sampled feature recording, and hugepage treatment). Update PageTracker::fully_freed() and HugePageFiller::AddToFillerList() to check empty() directly instead of comparing longest_free_range() to kPagesPerHugePage. Dense allocation now picks the lowest-index free page rather than intra-hugepage best-fit, trading minor hole-coalescing differences during subrelease for shorter pageheap_lock hold times. Retain the previous best-fit and eager longest_free_ maintenance under TCMALLOC_INTERNAL_LEGACY_LOCKING2.

Dense hugepages in `HugePageFiller` only serve 1-page spans and index trackers strictly by `nallocs()` rather than `longest_free_range()`, yet `PageTracker::Get` and `PageTracker::Put` still scan the full 256-bit `RangeTracker` bitmap on every allocation and deallocation under `pageheap_lock` to maintain `longest_free_`.

Parameterize `RangeTracker::FindAndMark`, `Mark`, and `Unmark` with `LongestFreeMode` (`kEager` vs `kLazy`) so dense `PageTracker` operations locate or flip a single bit with `FindClear(0)` without updating `longest_free_`, and compute `longest_free_range()` lazily via `ComputeLongestFree()` only for cold telemetry readers (stats printing, sampled feature recording, and hugepage treatment). Update `PageTracker::fully_freed()` and `HugePageFiller::AddToFillerList()` to check `empty()` directly instead of comparing `longest_free_range()` to `kPagesPerHugePage`. Dense allocation now picks the lowest-index free page rather than intra-hugepage best-fit, trading minor hole-coalescing differences during subrelease for shorter `pageheap_lock` hold times. Retain the previous best-fit and eager `longest_free_` maintenance under `TCMALLOC_INTERNAL_LEGACY_LOCKING2`.

PiperOrigin-RevId: 1034676187

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant