Repository navigation
[sgl-router] policies_reorg: affinity policy and the resolver affinity group - #40274
Closed
sherlockwu wants to merge 1 commit into
Closed
sherlockwu wants to merge 1 commit into
sherlockwu wants to merge 1 commit into
Conversation
…y group One AffinityPolicy serves session-aware and sticky routing: reuse an admitted binding for the request's key, otherwise let the fallback choose and bind its pick. HitRequired returns only an existing hit. The resolver gains an optional affinity group ahead of the size buckets, probed in HitRequired mode over the whole stage pool, and global-preserve stops later buckets from binding once a stranded binding is found. The factory wires both from the session and sticky settings. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Collaborator
Author
|
Closing: the series stops at the power-of-two PR (#40271) for now. |
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.
Motivation
Fourth PR of the engine-selection redesign, on top of #40273. Adds session and routing-key affinity on the new path, including the design's affinity-first group and global session modes.
Modifications
policies_reorg/affinity.rs:AffinityPolicy { kind: Session | Sticky, admission, store, global, fallback }. Session and sticky differ only in which request key they read and which fallback they get, so they share one implementation. An existing binding among the candidates is reused when it passes admission. Otherwise the fallback chooses among admitted candidates and the choice is bound (AffinityStore::bindkeeps a concurrent binding that is still a candidate). InHitRequiredmode the policy never falls back or binds, and it reports a binding held by a non-candidate as a rejection so the resolver can preserve it.PickRequestgainsmode,affinity_enabled, andaffinity_key(kind, global, value); keys arestage/kind/scope/valuewith scopeglobalor the bucket id.buckets_reorg.rs:Pool.affinity: Option<Arc<dyn Policy>>adds the affinity group ahead of the size buckets, over the stage pool filtered by each engine's own bucket context limit and SLO rule underslo_first.Pool.preserve_global_bindingimplements global-preserve: after the affinity group rejects a stranded binding, later groups run with affinity disabled. Bucket mode has no affinity group and scopes keys per bucket; global-rebind has the group and lets a size bucket rebind.admission::Admission::delegateruns a nested policy over the admitted candidates at the owner's placement; nested fallbacks useAllowAll.factory.rs:Dependencies { affinity: Arc<AffinityStore> }. Session-aware falls back to power-of-two; sticky to its configured fallback kind. The affinity group is enabled for sticky and for session-aware in a global mode when buckets are configured.pick_fallbackdefault is gone;fallback()remains the introspection hook.Metrics for sticky and session outcomes are deferred to the switch PR, where the legacy counters are reconciled.
Checklist
cargo clippy --locked --workspace --all-targets -- -D warningscleancargo test --lib policies_reorg(8) andcargo test --test component policies_reorg(7) pass🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #35410405514
Latest PR Test (Extra): ❌ Run #35410405349
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.