Conversation
543518e to
180f08a
Compare
to_i64 constructs an anyhow error containing a formatted TDim. Formatting hits Symbol::Display which locks the SymbolScope ReentrantMutex. With symbolic batch dims the error path fires every set_inputs, serializing all threads on the scope lock. as_i64 returns Option<i64> with no allocation and no lock — equivalent semantics as a concreteness probe. At 32 threads on LinearClassifier/100K-runs this restores perf from 197ms to 98ms (back to the fork-point baseline from 2026-01-09). Regressed in 106161a "graceful handling of missing hint for arena".
data already pinned parking_lot directly; hoisting to the workspace keeps the version lock-in centralized alongside the other pins.
SimplePlan::resolve calls guess_scenario on every set_input; models without scenarios (the common case) still paid a full scope lock just to observe that scenarios is empty. Under 32-way parallel inference that acquire/release was the dominant bottleneck (100% of scope-lock acquisitions counted during a LinearClassifier benchmark). Wrap the scope's Arc<ReentrantMutex<...>> in a SymbolScopeInner that also carries a lock-free `has_scenarios` AtomicBool, updated by add_scenario / add_scenario_assertion. guess_scenario checks it first and returns immediately when the scope has no scenarios. Deref on the wrapper keeps the `scope.0.lock()` call pattern working unchanged. LinearClassifier @ 100K runs, 32 threads: 100ms → 26ms. Now beats the PR #1942 RwLock approach (36ms) without the deadlock, since no lock at all beats a concurrent-reader lock.
180f08a to
21d7bf7
Compare
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.
No description provided.