fix(core): remove routing magic number, add BottleneckType::RoutingContention, harden analyzer and public API#19
Merged
Merged
Conversation
The scalar routing model used an opaque `overhead_fraction: f64` field that was silently converted via `(fraction * 10.0).ceil() as u32`. This made the TOML config non-self-documenting: setting `overhead_fraction = 0.5` actually meant 5 cycles, which is not obvious to users. Replace with a direct `overhead_cycles: u32` field (default 5, preserving the previous effective default). Remove `InvalidOverheadFraction` error variant since u32 needs no range validation. Update all TOML models, test fixtures, and tests.
…alidate() Prevents silent discard of simulation results. Engine::run() returns a Trace, run_monte_carlo() returns a MonteCarloResult, and validate() returns a ValidatedCircuit — all expensive to compute and useless if not captured.
…uide Replace the bare `assert!(size_of::<TraceEvent>() == 32)` with a documented block explaining why the budget exists (memory + cache efficiency), which variant is currently the largest, and three mitigation strategies for future contributors. Add a separate assertion on TraceEventKind (24 bytes) to pinpoint which part grew if the budget is exceeded.
…ng contention Two related fixes in the profile analyzer: 1. Clear factory_starts after consumption in FactoryProduced/FactoryFailed handlers. The analyzer previously relied on an implicit invariant that FactoryStarted always follows FactoryProduced/Failed. Clearing consumed starts makes the analyzer self-contained and correct regardless of trace ordering guarantees. Naive reference in test updated to match. 2. Add RoutingContention variant to BottleneckType to match the architecture spec (§4.5). Replace HAD_FAILURE with HAD_ROUTING — factory failures are part of factory throughput, not a separate bottleneck dimension. Track RoutingCompleted events with latency > 0. Classify buckets via (has_stall, has_routing) → Balanced/FactoryThroughput/RoutingContention/None. Add #[must_use] to ProfileAnalyzer::analyze().
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.
What
Five targeted fixes across pirx-hw, pirx-core, and pirx-ir: remove the scalar routing magic number, add
#[must_use] to key public functions, document the TraceEvent size budget, add defensive clearing in the
analyzer, and align BottleneckType with the architecture spec.
Why
How
Testing
make cipasses locally (fmt + clippy + test + audit)Checklist
unwrap()/expect()in production code