Skip to content

Order subrelease candidates by occupancy band and allocation time. - #1926

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

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

Conversation

@copybara-service

Copy link
Copy Markdown

Order subrelease candidates by occupancy band and allocation time.

When HugePageFiller::ReleasePages selects hugepage trackers to break, CompareForSubrelease currently ranks candidates by exact used-page count at single-page resolution and breaks ties only by span density. Because TryGet prepends to the front of its freelist on every allocation, ties among trackers with the same occupancy and density select the most recently allocated-from tracker first, and a single-page occupancy difference within a 16-page band overrides both span density and how long a tracker has been idle.

When Parameters::subrelease_order_by_allocation_time() (TCMALLOC_SONIC_SUBRELEASE_ORDER_BY_ALLOCATION_TIME) is enabled:

  • HugePageFiller::TryGet updates the tracker's last-allocation timestamp on every allocation using the clock sample already read on that path, and PageTracker::LastAllocationTime returns the maximum of tracker creation time and last page allocation time.
  • HugePageFiller::CompareForSubrelease groups used pages into 16-page occupancy bands and orders candidates by lower 16-page occupancy band first, sparse trackers ahead of dense trackers within the same band, oldest last-allocation timestamp first within the same band and density, and exact used-page count when timestamps are equal.

Subrelease ordering by allocation time is disabled by default.

Co-authored-by: Chris Kennelly ckennelly@google.com

@google-cla

google-cla Bot commented Nov 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

When `HugePageFiller::ReleasePages` selects hugepage trackers to break, `CompareForSubrelease` currently ranks candidates by exact used-page count at single-page resolution and breaks ties only by span density. Because `TryGet` prepends to the front of its freelist on every allocation, ties among trackers with the same occupancy and density select the most recently allocated-from tracker first, and a single-page occupancy difference within a 16-page band overrides both span density and how long a tracker has been idle.

When `Parameters::subrelease_order_by_allocation_time()` (`TCMALLOC_SONIC_SUBRELEASE_ORDER_BY_ALLOCATION_TIME`) is enabled:
- `HugePageFiller::TryGet` updates the tracker's last-allocation timestamp on every allocation using the clock sample already read on that path, and `PageTracker::LastAllocationTime` returns the maximum of tracker creation time and last page allocation time.
- `HugePageFiller::CompareForSubrelease` groups used pages into 16-page occupancy bands and orders candidates by lower 16-page occupancy band first, sparse trackers ahead of dense trackers within the same band, oldest last-allocation timestamp first within the same band and density, and exact used-page count when timestamps are equal.

Subrelease ordering by allocation time is disabled by default.

Co-authored-by: Chris Kennelly <ckennelly@google.com>
PiperOrigin-RevId: 1021515523

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.

0 participants