Skip to content

merge pr165 optimize rate_limiter() two fixs#166

Open
maverick123123 wants to merge 1 commit intoProject-HAMi:mainfrom
maverick123123:fix/rate_limiter
Open

merge pr165 optimize rate_limiter() two fixs#166
maverick123123 wants to merge 1 commit intoProject-HAMi:mainfrom
maverick123123:fix/rate_limiter

Conversation

@maverick123123
Copy link
Contributor

perf: optimize rate_limiter() by caching limits
rate_limiter() is called on every kernel launch when pidfound==1.
It was performing 3 shared memory reads, 1 shared memory write, and
2 ensure_initialized() calls before reaching the actual rate-limiting
CAS loop — all unnecessary per-call overhead.

Changes:

  • Cache sm_limit and utilization_switch in static locals during
    init_utilization_watcher(). These values are set at container
    startup and do not change at runtime.
  • Use cached values for the fast-exit check instead of reading from
    shared memory on every call. When limiting is inactive (sm_limit

    = 100 or == 0), rate_limiter becomes a single branch on a local
    variable.

Signed-off-by: Maverick123123 <yuming.wu@dynamia.ai>

Co-authored-by: Nishit Shah <nishshah@linkedin.com>
@hami-robot
Copy link
Contributor

hami-robot bot commented Mar 25, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: maverick123123
Once this PR has been reviewed and has the lgtm label, please assign archlitchi for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot bot added the size/S label Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant