feat(server): configurable CPU budgets per tick for simulation systems#156
Merged
feat(server): configurable CPU budgets per tick for simulation systems#156
Conversation
Cooperative CPU budget for tick-based systems. Systems call ctx.budget().is_expired() to yield early when time runs out. Systems that ignore the budget run to completion (backward-compatible). - TickBudget: tracks elapsed time against a configured limit - SystemContext::budget(): new trait method returning &TickBudget - SystemDescriptor.budget: optional Duration field - SystemBuilder::budget_ms(): declares the system's time budget
…gging Each system receives its own TickBudget based on its configured limit. Per-system timings are collected during both sequential and parallel dispatch. When a tick exceeds the expected duration, a warning is logged with a per-system timing breakdown. - Ecs: current_budget field, set_tick_duration(), tick_timings() - run_phase: creates budget per system, records elapsed time - dispatch_group: passes budget to ParallelSystemContext, collects timing - run_all: checks total elapsed against tick_duration threshold
Add [server.budgets] config section for per-system budget overrides. Operators can set budgets by system name or a global default_ms fallback. Config overrides take priority over builder-declared budgets. - BudgetsSection: default_ms + per-system overrides via serde(flatten) - Server startup applies config budgets and sets tick_duration for overrun detection - basalt-api re-exports TickBudget for plugin access - basalt-testkit SystemTestContext returns unlimited budget
Required for tick overrun warning logging in the ECS dispatcher.
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'ecs'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.
| Benchmark suite | Current: 6bc54ab | Previous: f1822bf | Ratio |
|---|---|---|---|
run_all_empty_systems |
54.6 ns/iter (± 0.86) |
26.41 ns/iter (± 0.29) |
2.07 |
This comment was automatically generated by workflow using github-action-benchmark.
Only call Instant::now() and collect per-system timings when tick_duration is set. This eliminates the ~25ns regression in run_all for the common case where overrun detection is not configured (e.g., benchmarks, tests).
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.
Summary
TickBudgetAPI onSystemContext— systems callctx.budget().is_expired()to yield early when time runs out, backward-compatible with systems that ignore it[server.budgets]section with per-system overrides by name and optionaldefault_msfallback (config > builder declaration > unlimited)TickBudgetinbasalt-apifor plugin accessCloses #124
Test plan
-D warnings)[server.budgets]to basalt.toml, verify overrun logging triggers with a tight budget (e.g.physics = 0)