Skip to content

feat: add priority-share admission control - #134

Open
andylokandy wants to merge 8 commits into
mainfrom
feat/priority-share-admission
Open

feat: add priority-share admission control#134
andylokandy wants to merge 8 commits into
mainfrom
feat/priority-share-admission

Conversation

@andylokandy

@andylokandy andylokandy commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add admission::PriorityShare as priority-bound handles over one shared capacity.
  • Configure cumulative admission thresholds through per-priority capacity increments.
  • Apply strict priority across levels and fair sharing between owners at the same priority.
  • Implement FairShare as the equivalent single-priority policy over the same scheduler.
  • Provide borrowed and owned acquisition APIs, custom hash builders, priority-scoped availability observations, model-based tests, and concurrency stress coverage.

Compatibility note: this removes the public FairShare::num_waiters() method introduced in v0.6.5.

Design Notes

Priorities are dense zero-based values ordered from lowest to highest. The constructor returns one handle per configured priority, and acquisition methods use the priority bound to that handle.

Capacity entries represent incremental headroom. The admission limit for priority p is the sum of entries through p, while every assigned permit counts toward every applicable shared threshold. For example, with [4, 1], priority 0 can enter while fewer than four permits are assigned, and priority 1 while fewer than five are assigned.

When capacity is released, the highest eligible priority is admitted first. Within that priority, the owner holding the fewest permits across all priorities is selected; ties follow queue order. The same owner may acquire or wait at multiple priorities.

Assigned permits are never revoked. Sustained higher-priority demand may starve lower priorities, and reserved headroom may remain unused while lower-priority work waits.

PriorityShare::available_permits() is scoped to its handle’s priority. Values from different handles overlap and must not be added together; the highest-priority handle reports total unassigned capacity.

@andylokandy
andylokandy force-pushed the feat/priority-share-admission branch from 4568bd5 to df9f159 Compare August 2, 2026 10:09
@andylokandy
andylokandy force-pushed the feat/priority-share-admission branch from df9f159 to 8da918c Compare August 2, 2026 11:42
Comment thread mea/src/admission/priority_share/tests.rs
Comment thread mea/src/admission/priority_share.rs Outdated

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under this design we may merge FairShare into PriorityShare because FairShare::new(n) is semantically identicial to PriorityShare::new([n]).

@andylokandy
andylokandy marked this pull request as ready for review August 4, 2026 12:44
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.

2 participants