Skip to content

Speed up restore placement by checking cpu_features last - #4103

Open
Abhay Joshi (abhayjoshi201) wants to merge 2 commits into
agent-substrate:mainfrom
abhayjoshi201:sched/cpu-features-fastpath
Open

Abhay Joshi (abhayjoshi201) wants to merge 2 commits into
agent-substrate:mainfrom
abhayjoshi201:sched/cpu-features-fastpath

Conversation

@abhayjoshi201

Copy link
Copy Markdown

The scheduler parsed every worker's cpu_features when placing an actor from a memory snapshot, even for workers rejected on another attribute, and even when the strings were identical.

matchesCompat now compares the exact-match attributes first. For cpu_features it returns early when the worker's string equals the snapshot's, and only parses the mask when they differ. Matching results don't change, so the existing TestMatchesCompat rows cover it.

A local matchesCompat benchmark (not included, benchstat over 8 runs):

case before after
identical cpu_features 159.8 ns 35.9 ns
bundle mismatch 167.2 ns 28.6 ns
superset, strings differ 163.5 ns 169.0 ns (no significant change)

Fixes #3924

AI use: AI-assisted for implementation and benchmarking. I reviewed and tested the change.

  • Tests pass
  • Docs updated

matchesCompat parsed each worker's cpu_features before comparing the
other attributes, so a worker with another architecture or bundle paid
for the parse before it was rejected. Compare the exact-match attributes
first, and return early when the worker's cpu_features string equals the
snapshot's. Workers on the same CPU platform and runsc build report the
same string.

Signed-off-by: Abhay Joshi <[email protected]>
@abhayjoshi201
Abhay Joshi (abhayjoshi201) marked this pull request as ready for review November 24, 2026 08:28
@abhayjoshi201

Copy link
Copy Markdown
Author

The e2e (envoy, gvisor) failure is the #4008 flake: TestRequestParking/BudgetExhaustion failed with "another operation is in progress for this actor". The other e2e lanes passed. Could someone rerun the failed jobs? I don't have permission to rerun them from my fork.

Shrutiya Mohan (@shrutiyam-glitch) this is ready for a look when you have time.

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.

Could someone rerun the failed jobs?

Amending and force-pushing (e.g. git commit --amend --no-edit && git push --force-with-lease) will re-trigger the full CI suite.
Currently, only a maintainer with write access can rerun just the failed job directly

}
// Workers on the same CPU platform and runsc build report the same
// string, and the snapshot's is already known to be canonical.
if wv == snapCPU {

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.

🤖 nit 🟢 – The wv == snapCPU shortcut relies on r.badCPUFeatures having already rejected non-canonical or invalid snapshot masks, so equal invalid masks on both sides still fail. None of the existing rows in TestMatchesCompat (internal/hardware/hardware_test.go:138-141) pass the same invalid or non-canonical value on both worker and snapshot. Consider adding a row (for example "07" on both sides) to pin that guard.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added a row with "07" on both sides. I checked it fails if the badCPUFeatures check is removed. The push also re-ran CI.

The equal-string shortcut in matchesCompat relies on the badCPUFeatures
check rejecting the snapshot's value first.

Signed-off-by: Abhay Joshi <[email protected]>

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.

ateapi: scheduling parses every worker's cpu_features on each placement

2 participants