Skip to content

Pr 1942 safe picks#2151

Merged
kali merged 3 commits intomainfrom
pr-1942-safe-picks
Apr 24, 2026
Merged

Pr 1942 safe picks#2151
kali merged 3 commits intomainfrom
pr-1942-safe-picks

Conversation

@kali
Copy link
Copy Markdown
Collaborator

@kali kali commented Apr 23, 2026

No description provided.

@kali kali force-pushed the pr-1942-safe-picks branch 2 times, most recently from 543518e to 180f08a Compare April 23, 2026 13:45
@kali kali mentioned this pull request Apr 23, 2026
kali added 3 commits April 23, 2026 15:35
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.
@kali kali force-pushed the pr-1942-safe-picks branch from 180f08a to 21d7bf7 Compare April 23, 2026 15:36
@kali kali merged commit 7fd44bc into main Apr 24, 2026
52 checks passed
@kali kali deleted the pr-1942-safe-picks branch April 24, 2026 06:57
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.

1 participant