You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(performables): avoid allocation in ready blocking operations - #810
Blocking channel operations and async-capable barrier waits allocate a thread waker even when they can finish immediately. This adds avoidable allocation and latency to ready operations, unlike the existing uncontended mutex and reader-writer-lock fast paths.
Approach
Attempt queue send/receive, oneshot receive, watch change, and barrier arrival directly before entering the shared blocking adapter.
Preserve existing waiting machinery for pending operations, once-per-operation contention recording, a single barrier arrival, and timeout deadlines captured before readiness checks.
Add native zero-allocation regressions, deterministic pending-path success/closure tests, a full-queue blocking-send telemetry assertion, and ready-operation benchmarks. Allocation checks live in ready_blocking_allocations.rs.
Document generation/deadline/contention handoffs, fixture setup, scheduling safeguards, and the requirement to use asynchronous waits on executor workers needed by other participants.
No public API changes relative to current main. Base integration retains main's crate-root Error, sync::{Async, Sync}, and BarrierWaitOutcome APIs from #820. Queue payload storage and enabled telemetry may allocate independently. Final async-capable barrier arrivals avoid allocating their own waiter storage; this does not promise allocation-free release of other waiters. Pending operations retain their existing blocking and cancellation behavior.
Benchmark comparison
Compared against unmodified main at 131f7d6a, with identical benchmark source, Rust 1.95, all features, fat LTO, and one logical CPU on Windows x64 / AMD Ryzen 7 PRO 7840U. Ran baseline/optimized/optimized/baseline, with 100 samples, 1-second warm-up and 2-second measurement per case. Values average the two independent-run medians. Before/after 95% confidence intervals remained separated across both repeats for every case.
Measurements were taken at original commit b3d78d3 (replayed as 6f4830e6), before later naming, documentation, test-only follow-ups, and base integrations. Reported benchmark identities and measured operations remain unchanged; synchronization type paths were adapted to #820. These timings were not rerun after the follow-ups, rebase, or merges.
Ready blocking operation
Before
After
Latency reduction
Bounded queue send
96.5 ns
29.6 ns
69.3%
Unbounded queue send
107.9 ns
38.5 ns
64.3%
Bounded queue receive
113.9 ns
36.1 ns
68.3%
Unbounded queue receive
118.4 ns
38.8 ns
67.3%
Bounded queue timed receive
156.4 ns
78.9 ns
49.5%
Unbounded queue timed receive
150.2 ns
79.1 ns
47.3%
Oneshot receive
150.5 ns
79.5 ns
47.2%
Oneshot timed receive
195.0 ns
106.1 ns
45.6%
Watch change
104.9 ns
25.5 ns
75.7%
Async-mode barrier wait
110.8 ns
31.5 ns
71.5%
These are already-ready microbenchmarks, not contended throughput or end-to-end application speedups. Independent allocation tests reproduce one thread-waker allocation per ready call before the change and zero afterward, with queue payload storage prepared outside measurement.
Base integration and CI corrections
Current head 676aeecc merges main at f660d7c6. The sole textual conflict was in Arty's worker-wait regression, where #843 independently introduced a fuller deterministic-cleanup fix. The merge retains upstream's public cancellation test and private consuming-stop regressions, including all shutdown-completion joins, and removes this branch's superseded duplicate. Arty is now identical to main; the PR is back to a 12-file diff. The optimization, allocator and Seismograph files are unchanged from the previously passing head 627e1f59. The lockfile difference remains only the performables allocation-test dependency.
Earlier integration preserved #820's diagnostics APIs/documentation and cargo-anvil 0.14.0 from #831. The generated crate README was regenerated, not edited by hand. The branch also includes the Quinn security fix from #816 and subsequent upstream lockfile updates; no advisory ignores were added.
Existing test defects were corrected without changing those crates' production behavior:
16f6f6f2 (formerly 5fb3b7dd): the allocator concurrent-publication test drains at least once before checking whether producers finished, so scheduling cannot skip its consumer loop. All original uniqueness, completeness, and tail-retention assertions remain.
ec8c2569 (formerly 84acafd8): the Seismograph clear-buffer test distinguishes active allocation reuse from valid retired-thread cleanup. An explicit retired-thread fixture reproduced the old failure deterministically: total allocation fell from 37264 to 18832 bytes, the same 18432-byte difference seen in CI. The corrected test checks active ring allocation identity/capacity across enabled/disabled clear, exact policies and event counts, and actual retired-ring release. Fallible statistics prevent observation errors from appearing as empty results. 62e0073b (formerly 75fae2ab) gives the fixtures safely owned process-lifetime references, removing both new pointer dereferences reported by CodeQL without suppressing or dismissing alerts.
The Windows Miri shutdown failure led to 627e1f59: nested runtime owners consumed on an async worker correctly request shutdown without waiting, so the regression needed retained completion handles and off-worker joins. That implementation is now superseded by the equivalent, broader upstream #843 tests, not dropped without replacement. No production runtime behavior or public API was changed by that follow-up.
d7f12241 (formerly a7b9fff0) addresses documentation/readability feedback with concise contracts, generated README updates, and worker-local handle ownership. All 14 threads from that review and both later CodeQL threads were replied to and resolved. Watchdogs and mutation cases remain enabled; no requested exclusions or watchdog disabling were introduced.
Validation
Latest integration (676aeecc)
Full workspace just anvil-clippy passes, as does explicit Rust 1.95 all-feature/all-target Clippy for arty, arty_executor, performables, rallocator and seismograph. The earlier local Spectre-library prerequisite blocker is no longer present in this validation.
Combined native suites for those five packages pass: 908 all-feature tests and 706 no-default tests, with two existing skips in each configuration. Debug and release all-feature builds pass.
Both retained cancellation-destructor regressions (private consuming-stop coverage and public integration coverage) pass the existing Anvil Miri runner across 16 scheduling seeds. The upstream self-stop regression also passes 16 seeds. Other filtered executables have no matching tests; this is not a fresh full Arty Miri suite.
Anvil formatting, generated README regeneration and spellcheck pass, with no generated-file drift. No runtime behavior, Miri leak diagnostics, assertions, resource limits or thresholds were weakened to resolve the conflict.
Fresh provider CI must validate 676aeecc; passing checks on 627e1f59 do not establish current-head success.
Earlier measured evidence (not rerun on the latest merge)
Exact Windows source coverage was measured after the prior semantic merge at a1d069ce, with zero raw uncovered LCOV source lines in both feature configurations:
Package
Exact Windows source coverage
performables
3790/3790 (100%)
rallocator
3815/3815 (100%)
seismograph
6945/6945 (100%)
Arty was measured at 1563/1563 after 627e1f59; subsequent upstream lifecycle refactoring changes its source inventory, so that historical total is not a current Arty coverage claim. Linux coverage passed at 100% before the base integrations and must be reconfirmed by fresh CI. No fresh complete local Anvil PR-tier success is claimed.
Both channel and barrier unit-test modules use #[cfg_attr(coverage_nightly, coverage(off))] for test-harness code; their tests and assertions still execute, and their exercised production paths remain measured. The latest conflict resolution adds no coverage or mutation exclusions relative to current main.
Performables' standard Miri run after the earlier semantic merge passed all ten executables. The Seismograph regression previously passed standard, Tree Borrows and strict-provenance Miri; those full/profile runs were not repeated after the latest merge.
PR changed-line mutation testing after the earlier semantic merge passed: 22 mutants, 14 caught and 8 unviable, no misses or timeouts. The try_changed -> None replacement remains enabled and was caught. The latest merge leaves all PR-specific production changes unchanged; no fresh complete mutation campaign is claimed for this merge.
Prior Ubuntu selected library/channel/zero-allocation binaries passed 172 all-feature and 170 no-default tests. This is not a new full Ubuntu workspace run.
The earlier Linux Bolero memory-limit exit was investigated without code/limit changes: its recorded seed passed a full local empty-corpus campaign, and only the failed Linux job was retried. The Windows Miri retry was followed by the actual deterministic cleanup fix rather than treating a retry as a code correction.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (0c8f690) to head (676aeec). ⚠️ Report is 2 commits behind head on main.
Reviewed commit: b3d78d3b37dd34f5066e8a4ab3e3f0447a67587d
Base commit: 131f7d6a89a6dcef213179a9b5283a769d025a3c
Review time: 2026-10-13T06:19:48Z
I reviewed the public contract and API, correctness and concurrency, tests, performance and allocation behavior, naming, telemetry, resilience, source/documentation consistency, and integration tests. Generated README wording was excluded because it is repository-generated.
Focused all-feature tests, allocation guards, benchmark compilation, public API captures, and base/head integration tests passed. No base-versus-head timing or instruction-count comparison was run, so latency claims were not measured. Linux CI reports 99.9% coverage for its flag despite 100% patch coverage.
Public API changes
No API Changes
The complete all-feature performables 0.2.0 public surfaces at base and head are identical.
Integration tests
No Breaking Behavioral Changes
Existing behavior is preserved; tests add zero-timeout/final-version channel coverage and allocation-free ready-operation coverage.
Current findings
Posted by an AI agent · Non-blocking
Contended blocking sends lack a telemetry regression assertion
Problem
The telemetry test proves ready Sender::send calls emit no contention, but never exercises the new full-queue blocking branch or verifies that it emits exactly one ChannelSendContention event.
Why this matters
A future change could omit or duplicate contention telemetry while all current behavioral and allocation tests continue passing.
Suggested fix
Add a full bounded-queue scenario that blocks send, releases capacity, and asserts exactly one send-contention event.
Posted by an AI agent · Non-blocking
Barrier unit tests remain included in coverage accounting
Problem
New tests were added to barrier.rs without the repository's #[cfg_attr(coverage_nightly, coverage(off))] test-module convention, although the modified channel test module applies it.
Why this matters
Coverage reports mix test-harness execution with production coverage and become inconsistent across the changed modules.
Suggested fix
Apply #[cfg_attr(coverage_nightly, coverage(off))] to the barrier mod tests.
Posted by an AI agent · Nit
Private channel futures omit the established _async suffix
Problem
The new send_with_recording, recv_with_recording, and changed_with_recording functions are async, while every sibling async operation and the crate-level convention use an _async suffix.
Why this matters
Unsuffixed names imply blocking operations in this crate, obscuring whether callers must await or block_on them.
Suggested fix
Rename them to send_with_recording_async, recv_with_recording_async, and changed_with_recording_async.
Posted by an AI agent · Nit
Benchmark symbols omit parts of their reported operation names
Problem QUEUE_TIMEOUT/queue_timeout, ONESHOT_TIMEOUT/oneshot_timeout, and BARRIER_ASYNC/barrier_async diverge from their benchmark names queue_recv_timeout, oneshot_recv_timeout, and barrier_async_blocking. Sibling MUTEX_LOCK_PERFORMABLES_ASYNC_BLOCKING preserves the complete reported name.
Why this matters
Searching benchmark output does not lead directly to the corresponding source symbol, and barrier_async can be mistaken for benchmarking wait_async().
Suggested fix
Use QUEUE_RECV_TIMEOUT/queue_recv_timeout, ONESHOT_RECV_TIMEOUT/oneshot_recv_timeout, and BARRIER_ASYNC_BLOCKING/barrier_async_blocking.
Posted by an AI agent · Nit
The channel_allocations test binary now covers non-channel synchronization
Problem
The file describes ready blocking operations generally and includes a Barrier allocation test, while sibling channel.rs is channel-specific and broad synchronization tests use broader names such as sync.rs.
Why this matters
The test binary name no longer identifies its contents, making allocation failures for barriers appear under a channel-only target.
Suggested fix
Rename the file to ready_blocking_allocations.rs.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The stated coverage exclusions do not match the channel test-module exclusion in the diff.
0 open findings
Previously missed (1)
In code that hasn't changed since last review
Disclose or remove channel unit-test coverage exclusion
crates/performables/src/sync/channel.rs:1326
The validation notes say that only the barrier test harness was excluded from coverage, but this also disables coverage for the entire channel unit-test module, including the newly added pending-path tests. Please either remove this second exclusion or update the PR validation notes to disclose and explain it.
Add direct channel and async barrier fast paths while preserving shared waiting behavior, timeout deadlines, and contention telemetry. Guard ready-path allocation counts and pending-path behavior with deterministic tests.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0e05ef33-3180-4057-9d92-e49459d4e7a8
Assert exactly one contention event for a full-queue blocking send, align private async and benchmark names, rename allocation guards, and clarify the async barrier blocking contract. Exclude only the barrier test harness from coverage accounting.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0e05ef33-3180-4057-9d92-e49459d4e7a8
Drain at least once before checking producer completion, retaining the original uniqueness, completeness, and tail-retention assertions.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0e05ef33-3180-4057-9d92-e49459d4e7a8
Exercise retired history explicitly, then verify active ring storage identity and capacity, retired ring release, exact recording policies, and retained events. Use fallible statistics so errors cannot appear as successful empty observations.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0e05ef33-3180-4057-9d92-e49459d4e7a8
Resolve the worker-wait test conflict using main's fully joined private regressions and public cancellation coverage. Remove the superseded duplicate while preserving the optimization changes unchanged.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0e05ef33-3180-4057-9d92-e49459d4e7a8
…ths (#854)
## Summary
Consolidate the Performables synchronization performance work, including
the remaining useful changes from
[#810](#810). This PR
supersedes the need to merge #810 separately; it does not close that PR.
The performance target is telemetry compiled in with recording disabled,
while preserving live recording switches and existing synchronization
contracts.
## Changes
- Add owned atomic/address-parking Mutex and RwLock backends for
Windows/Linux, with portable std-backed fallbacks. Preserve poisoning,
recovery, const construction and native guard thread affinity.
- Streamline disabled Seismograph recording, Arc capture/drop
bookkeeping and initialized OnceLock/LazyLock paths. Keep enabled
recording covered by dedicated telemetry tests.
- Try ready queue, oneshot, watch and Async-barrier operations before
creating blocking adapters. Preserve the original finite timeout budget,
one contention event and one barrier arrival. Empty native Condvar
notifications and one-participant barriers have direct fast paths.
- Add Sync/Async Notify with a retained/coalesced permit, waiter
enablement, cancellation handoff and blocking/async waits. Use it for
Arty worker signaling while preserving main's deadline-driven timers and
tests for sleeping and waking runtime threads.
- Use reusable generational indexed waiters with O(1) unlinking and
eight cache-separated watch shards. Preserve the paired sequentially
consistent publication/registration fences established by the protocol
models.
- Add matched std/Tokio comparisons, allocation probes, watch scaling
workloads and public edge-case coverage informed by the std/Tokio test
audit.
### Review follow-up
Finite elapsed-time budgets handle durations that overflow Instant
without becoming unlimited waits. Notify records its signal before
reentrant wake delivery; monitor/thread/report labels distinguish permit
misses from physical blocking. Controlled
registration/expiry/spurious-wake tests, queued cancellation and
reentrant telemetry-order tests cover these paths. The portable
poison-notification test rechecks its predicate after a spurious wake.
Watch fanout retains single-shard and eight-thread spread registration,
with identical controls and setup outside timing. The empty-Condvar
group no longer compares against retained Tokio permits. Target-specific
size reporting replaces unsupported relative-layout assertions;
allocation guarantees have explicit recording/payload/waker/platform
boundaries.
Follow-up **1fbe6812** adds
[design](https://github.com/microsoft/oxidizer/blob/1fbe6812/crates/performables/docs/design.md)
and
[implementation](https://github.com/microsoft/oxidizer/blob/1fbe6812/crates/performables/docs/implementation.md)
guides, protocol/ordering explanations, grouped helper types and
imports, type-derived private diagnostics, unwind-safety assertions, and
explicit required features for the five new telemetry test targets. The
watch harness uses many_cpus discovery and unchanged sample boundaries
and workload cases. Its initial driver-free Tick stopwatch was replaced
by `std::time::Instant` in **37b22763**, because Tick itself depends on
Performables and the dev-dependency created a cycle. Unmeasured
private/generic inline hints were removed; the documented HAL boundaries
and exported non-generic hot paths remain. This follow-up changes no
public Rust API or production synchronization algorithm.
### Remaining #810 consolidation
Port the allocator test's at-least-once drain, the safe active/retired
recorder-buffer fixture, nine standalone blocking-channel benchmarks,
blocking-first barrier regressions and generation assertions, and
Miri-eligible ready/blocking telemetry coverage.
Retain the integrated Error/ErrorKind, Sync/Async/Mode and outcome names
and Arty shutdown/teardown fixes. Notify is the public addition; native
backend associated types remain implementation details.
## Performance evidence
**These timings are historical measurements before the later base
integrations and review follow-ups, not measurements of the current PR
head.** They came from a real Azure Standard_HB176rs_v4 with 176
available physical cores, SMT off, Rust 1.95, ordinary
release/x86-64-v3, and telemetry compiled in but disabled. The requested
172-worker configuration was included.
Critical watch cancellation workload, 256 retained pending waits per
worker; microseconds per round, with one operation per worker per round.
Values average two matched Criterion point estimates, not pooled
confidence intervals:
| Workers | Performables | Tokio | std-mutex fixture |
| ---: | ---: | ---: | ---: |
| 172 | 43.31 | 109.68 | 3109.51 |
| 176 | 43.73 | 111.19 | 3214.78 |
At 176 workers, this is 60.7% less time than Tokio and 98.6% less than
the fixture. **std has no watch primitive**: the control is a simple
mutex-backed boolean broadcast fixture with linear cancellation, not a
native std watch. These results do not imply linear core scaling.
Actual uncontended primitive comparisons on one pinned core,
nanoseconds:
| Operation | Performables | std | Tokio |
| --- | ---: | ---: | ---: |
| Sync Mutex lock/unlock | 4.63 | 4.36 | 16.92 |
| Sync RwLock read | 5.21 | 4.93 | 16.67 |
| Sync RwLock write | 5.43 | 4.56 | 16.89 |
| Ready bounded blocking send + receive | 14.97 | 19.30 | 52.10 |
The synchronous locks still take approximately 6-19% more time than std
on that machine; this is not a universal std win. Tokio lock controls
poll ready async locks rather than providing poisoning synchronous
locks. Performables queues are MPMC while the std/Tokio controls have
one receiver. No HTTP server throughput claim is made.
## Tradeoffs and boundaries
Reusable storage retains peak slot capacity until channel destruction,
and padding/shards increase idle memory. The sizes example measures
shared watch construction as well as inline sizes: an empty bool watch
requested one 1344-byte allocation versus Tokio's one 352-byte
allocation on both measured x64 hosts. This is requested heap storage,
not RSS or allocator size classes, and not a stable layout promise. The
high-core cancellation workload motivates the fixed sharding cost.
Cancellation releases wakers/task references while retaining reusable
storage.
Channel/watch value borrows remain exclusive so Send-but-not-Sync
payloads continue to work. The unfinished allocation-event symbolization
and HTML-viewer-removal work remains an unpublished draft and is not
included here.
## CI cost and mutation policy
Required CI was fully green on **b7f92784** before the new review
follow-up. Earlier pruning removed a test-only OS-call counter and a
start-only unpark smoke test, retained native state/wakeup tests, and
excluded equivalent futex OR/XOR mutations rather than adding artificial
constant assertions. Reproduced progress-breaking mutation exclusions
reduced the earlier Linux mutation jobs from roughly three hours to
about 23-35 minutes. This is not an end-to-end CI-duration claim: a
historical Linux runtime-analysis job still took about 133 minutes.
**Performables alone retains a 99.8% minimum line-coverage policy.** The
earlier Linux report measured 4211/4216 lines (99.8814%); its five
misses were safe atomic compare-exchange retry reload assignments in
watch, RwLock and Notify. The loops remain measured. This is an
intentional package-specific exception to the usual 100% target for
unsafe crates, not a global threshold change. Coverage subsequently
passed on b7f9278; this follow-up does not lower the target again.
Only mutation runs skip the compiler-subprocess `type_system_contracts`
UI test. Native, coverage and cargo-careful suites retain those
contracts; compile-time trait assertions still compile during mutation
testing. The native OS-clock timeout smoke remains native/careful, while
deterministic ownership, registration, expiry and spurious-wake cases
remain under Miri.
The review follow-up makes the affected test-local progress watchdogs
honor `testing_aids::is_mutation_testing()`. It does not disable
functional timeout tests. Under mutation testing, last-chance
registration clocks are not initialized and completion joins, receives
and parks are unbounded, allowing the mutation runner to distinguish
non-termination from an immediate behavioral failure. Test-only clock
setup is isolated under cfg(test), rather than scored as production
mutation coverage.
Bounded native audits with that mode enabled exposed **37 additional
concrete non-terminating mutation identities**: eight from the Windows
wake-removal probe, one from the Linux wake-removal probe, and 28 from
the Windows PR-diff audit. Those exact variants are excluded
consistently; other mutations in the same methods remain selected.
**Linux `wake_condition_all` deletion is intentionally excluded in the
current configuration**, after the Ubuntu probe reproduced its hang. The
older b7f9278 audit had retained it; that historical result must not be
read as the current selection.
Mutation timeouts still fail the check. Excluded hangs are not counted
as caught, normal tests and assertions remain, and neither caches nor
the remaining Miri checks are bypassed.
## Verification for the review follow-up
- Anvil formatting, full workspace Clippy, README regeneration, spelling
and manifest checks passed.
- Windows: 393 selected all-feature tests passed (389 Performables,
three Arty worker-guard cases and the recorder-lifecycle fixture). The
isolated Performables no-default suite passed all 377 tests. The final
clock-helper cleanup was followed by another successful 389-test
all-feature run and debug/release Performables/Arty builds.
- Focused Anvil Miri passed six notification protocol tests and four
portable ownership/poison/wakeup tests. This is not a new complete Miri
sweep.
- Criterion test mode executed all three one-worker watch read/clone
controls successfully. Optimized ready-benchmark IR before/after hint
removal showed no added calls through the removed Performables helper
boundaries on this Windows target. These checks are not fresh
comparative timings.
- Explicit telemetry-test selection without seismograph now rejects the
command with Cargo's missing-feature diagnostic, rather than reporting
an empty successful run.
- The Windows wake-removal audit ran 20 mutants: 12 caught, eight
timeouts. The Ubuntu audit ran 14: 13 caught, one timeout.
- The broader Windows PR-diff audit ran 428 mutants in 32 minutes: 183
caught, 215 unviable, 28 timeouts and two missed test-clock expressions.
The clock expressions were moved outside mutation-selected production
bodies; the recorded non-terminating variants were narrowly excluded.
- The final Windows PR-diff enumeration for that follow-up retained 397
identities, every one matched to a previously caught or unviable
identity. Both retained cancellation and finite-timeout faults were
rerun and caught. **This historical selection audit is not a completed
mutation run for the later base integrations.**
Earlier integrated-source checks also passed broad Windows/Ubuntu
suites, optimized Performables/Arty/Tick suites, doctests and all 51
ready instruction-count benchmark cases. The earlier allocation probe
reported zero allocations/bytes for warmed operations, excluding an
unmatched empty Tokio control that has since been removed.
## Subsequent integration and CI repair
The branch incorporates main's native monitor transport and Arty
I/O-driver integration. Worker signaling keeps Notify while retaining
the driver-interrupt waker and pending-notification consumption required
by the new I/O wait path.
CI on **c7724c1a** exposed a benchmark-only dependency cycle, a missed
close-telemetry mutation, a mixed-contention test completion timeout,
and an I/O test requesting three processors on two-processor external
runners. **37b22763** makes six narrowly scoped file changes:
- Remove `performables`' Tick dev-dependency and use a standard
monotonic benchmark timer over the existing barrier interval. Library
timing APIs and benchmark workload cases remain unchanged.
- Keep the watch allocation live throughout the telemetry fixture and
require exactly one close event for its object and thread. This prevents
recycled channel addresses from satisfying the wrong assertion. The
exact previously missed receiver-drop subtraction-to-addition mutant is
now caught; no mutation exclusion was added.
- Keep four mixed reader/writer roles, yield placement, coherence
assertions, exact final count and the five-second liveness watchdog,
while reducing redundant native repetitions from 2,000 to 64. Miri keeps
its existing eight repetitions. The original workload passed 100
instrumented local runs before this reduction; no production lock change
or coverage exclusion is claimed.
- Run the three-worker I/O failure scenario only when three processors
are available, matching existing hardware-capability guards. Its
complete assertions remain active on capable hosts; the other I/O
scenarios still run on two-processor runners.
Local verification for this repair passed the Anvil quality gates
including dependency-cycle detection, 790 affected all-feature native
tests, 377 isolated no-default-feature Performables tests, all 25
instrumented synchronization-mode tests, the focused release I/O
regression, all host-selected watch benchmark smoke cases, and
debug/release builds. The single missed mutation was rerun and caught.
Optional external SARIF/SBOM publication-evidence diagnostics were not
bypassed or patched into this performance change.
No public API, production synchronization code, coverage threshold,
mutation configuration, cache or required check was changed by that
repair. Those results describe the historical **37b22763** repair, not
the latest PR head.
### Latest base refresh and lint repair
The branch includes main through **11d82cff**, including the repository
agent policies and socket-address ThreadAware implementations. The
rebased tree matched an independent clean merge result before the
following test-only repair.
Azure build **43040594** passed all **10,086 Linux native tests** and
completed its doctests. Its Linux development job failed afterward
because Clippy 1.97 treated the `PublishOnDrop` test helper as a
replaceable no-op waker. **dc2bee8a** keeps publication in `Drop` and
rejects an unexpected wake. The cleanup behavior and existing assertions
remain unchanged. No lint suppression or coverage exclusion was added.
The rebased source passed 822 selected all-feature native tests, three
no-default-feature ThreadAware-core tests, the selected doctests, and
debug/release all-target builds. After the fixture repair, Clippy passed
on both Rust 1.95 and 1.97. All 11 watch-contention tests passed with
all features and again without default features. Anvil formatting,
workspace Clippy, README regeneration and spelling passed, as did the
scoped debug/release builds.
Follow-up **2f6de79a** adds a compile-time power-of-two check for the
existing shard bitmask and completes the same drop-only fixture repair
for Notify and queues. It preserves the eight-shard layout, cleanup
callbacks, all existing assertions, and public APIs. The two benchmark
lifetime comments required no code changes: Rust 1.95 defines
`Waker::noop()` as returning `&'static Waker`, and the exact uncontended
benchmark check passed.
For that follow-up, the full standard Anvil Clippy check passed before
the final two fixture edits. The changed targets then passed Clippy
1.95, and the entire Performables package passed all-target Clippy 1.97
with warnings denied. All 390 all-feature tests passed with one existing
skip, and all 377 no-default-feature tests passed. Debug/release
all-target builds, formatting, README regeneration and spelling passed.
No coverage or mutation exclusions were added.
Fresh required CI must validate the latest pushed head. No new complete
remote coverage or mutation result is claimed for that head.
No fresh final-head 176-core timing or complete local PR tier is
claimed. Required CI remains authoritative for the latest pushed head.
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bda2a0b-7dbf-4d57-a10b-456b744da539
…ths (#854)
## Summary
Consolidate the Performables synchronization performance work, including
the remaining useful changes from
[#810](#810). This PR
supersedes the need to merge #810 separately; it does not close that PR.
The performance target is telemetry compiled in with recording disabled,
while preserving live recording switches and existing synchronization
contracts.
## Changes
- Add owned atomic/address-parking Mutex and RwLock backends for
Windows/Linux, with portable std-backed fallbacks. Preserve poisoning,
recovery, const construction and native guard thread affinity.
- Streamline disabled Seismograph recording, Arc capture/drop
bookkeeping and initialized OnceLock/LazyLock paths. Keep enabled
recording covered by dedicated telemetry tests.
- Try ready queue, oneshot, watch and Async-barrier operations before
creating blocking adapters. Preserve the original finite timeout budget,
one contention event and one barrier arrival. Empty native Condvar
notifications and one-participant barriers have direct fast paths.
- Add Sync/Async Notify with a retained/coalesced permit, waiter
enablement, cancellation handoff and blocking/async waits. Use it for
Arty worker signaling while preserving main's deadline-driven timers and
tests for sleeping and waking runtime threads.
- Use reusable generational indexed waiters with O(1) unlinking and
eight cache-separated watch shards. Preserve the paired sequentially
consistent publication/registration fences established by the protocol
models.
- Add matched std/Tokio comparisons, allocation probes, watch scaling
workloads and public edge-case coverage informed by the std/Tokio test
audit.
### Review follow-up
Finite elapsed-time budgets handle durations that overflow Instant
without becoming unlimited waits. Notify records its signal before
reentrant wake delivery; monitor/thread/report labels distinguish permit
misses from physical blocking. Controlled
registration/expiry/spurious-wake tests, queued cancellation and
reentrant telemetry-order tests cover these paths. The portable
poison-notification test rechecks its predicate after a spurious wake.
Watch fanout retains single-shard and eight-thread spread registration,
with identical controls and setup outside timing. The empty-Condvar
group no longer compares against retained Tokio permits. Target-specific
size reporting replaces unsupported relative-layout assertions;
allocation guarantees have explicit recording/payload/waker/platform
boundaries.
Follow-up **1fbe6812** adds
[design](https://github.com/microsoft/oxidizer/blob/1fbe6812/crates/performables/docs/design.md)
and
[implementation](https://github.com/microsoft/oxidizer/blob/1fbe6812/crates/performables/docs/implementation.md)
guides, protocol/ordering explanations, grouped helper types and
imports, type-derived private diagnostics, unwind-safety assertions, and
explicit required features for the five new telemetry test targets. The
watch harness uses many_cpus discovery and unchanged sample boundaries
and workload cases. Its initial driver-free Tick stopwatch was replaced
by `std::time::Instant` in **37b22763**, because Tick itself depends on
Performables and the dev-dependency created a cycle. Unmeasured
private/generic inline hints were removed; the documented HAL boundaries
and exported non-generic hot paths remain. This follow-up changes no
public Rust API or production synchronization algorithm.
### Remaining #810 consolidation
Port the allocator test's at-least-once drain, the safe active/retired
recorder-buffer fixture, nine standalone blocking-channel benchmarks,
blocking-first barrier regressions and generation assertions, and
Miri-eligible ready/blocking telemetry coverage.
Retain the integrated Error/ErrorKind, Sync/Async/Mode and outcome names
and Arty shutdown/teardown fixes. Notify is the public addition; native
backend associated types remain implementation details.
## Performance evidence
**These timings are historical measurements before the later base
integrations and review follow-ups, not measurements of the current PR
head.** They came from a real Azure Standard_HB176rs_v4 with 176
available physical cores, SMT off, Rust 1.95, ordinary
release/x86-64-v3, and telemetry compiled in but disabled. The requested
172-worker configuration was included.
Critical watch cancellation workload, 256 retained pending waits per
worker; microseconds per round, with one operation per worker per round.
Values average two matched Criterion point estimates, not pooled
confidence intervals:
| Workers | Performables | Tokio | std-mutex fixture |
| ---: | ---: | ---: | ---: |
| 172 | 43.31 | 109.68 | 3109.51 |
| 176 | 43.73 | 111.19 | 3214.78 |
At 176 workers, this is 60.7% less time than Tokio and 98.6% less than
the fixture. **std has no watch primitive**: the control is a simple
mutex-backed boolean broadcast fixture with linear cancellation, not a
native std watch. These results do not imply linear core scaling.
Actual uncontended primitive comparisons on one pinned core,
nanoseconds:
| Operation | Performables | std | Tokio |
| --- | ---: | ---: | ---: |
| Sync Mutex lock/unlock | 4.63 | 4.36 | 16.92 |
| Sync RwLock read | 5.21 | 4.93 | 16.67 |
| Sync RwLock write | 5.43 | 4.56 | 16.89 |
| Ready bounded blocking send + receive | 14.97 | 19.30 | 52.10 |
The synchronous locks still take approximately 6-19% more time than std
on that machine; this is not a universal std win. Tokio lock controls
poll ready async locks rather than providing poisoning synchronous
locks. Performables queues are MPMC while the std/Tokio controls have
one receiver. No HTTP server throughput claim is made.
## Tradeoffs and boundaries
Reusable storage retains peak slot capacity until channel destruction,
and padding/shards increase idle memory. The sizes example measures
shared watch construction as well as inline sizes: an empty bool watch
requested one 1344-byte allocation versus Tokio's one 352-byte
allocation on both measured x64 hosts. This is requested heap storage,
not RSS or allocator size classes, and not a stable layout promise. The
high-core cancellation workload motivates the fixed sharding cost.
Cancellation releases wakers/task references while retaining reusable
storage.
Channel/watch value borrows remain exclusive so Send-but-not-Sync
payloads continue to work. The unfinished allocation-event symbolization
and HTML-viewer-removal work remains an unpublished draft and is not
included here.
## CI cost and mutation policy
Required CI was fully green on **b7f92784** before the new review
follow-up. Earlier pruning removed a test-only OS-call counter and a
start-only unpark smoke test, retained native state/wakeup tests, and
excluded equivalent futex OR/XOR mutations rather than adding artificial
constant assertions. Reproduced progress-breaking mutation exclusions
reduced the earlier Linux mutation jobs from roughly three hours to
about 23-35 minutes. This is not an end-to-end CI-duration claim: a
historical Linux runtime-analysis job still took about 133 minutes.
**Performables alone retains a 99.8% minimum line-coverage policy.** The
earlier Linux report measured 4211/4216 lines (99.8814%); its five
misses were safe atomic compare-exchange retry reload assignments in
watch, RwLock and Notify. The loops remain measured. This is an
intentional package-specific exception to the usual 100% target for
unsafe crates, not a global threshold change. Coverage subsequently
passed on b7f9278; this follow-up does not lower the target again.
Only mutation runs skip the compiler-subprocess `type_system_contracts`
UI test. Native, coverage and cargo-careful suites retain those
contracts; compile-time trait assertions still compile during mutation
testing. The native OS-clock timeout smoke remains native/careful, while
deterministic ownership, registration, expiry and spurious-wake cases
remain under Miri.
The review follow-up makes the affected test-local progress watchdogs
honor `testing_aids::is_mutation_testing()`. It does not disable
functional timeout tests. Under mutation testing, last-chance
registration clocks are not initialized and completion joins, receives
and parks are unbounded, allowing the mutation runner to distinguish
non-termination from an immediate behavioral failure. Test-only clock
setup is isolated under cfg(test), rather than scored as production
mutation coverage.
Bounded native audits with that mode enabled exposed **37 additional
concrete non-terminating mutation identities**: eight from the Windows
wake-removal probe, one from the Linux wake-removal probe, and 28 from
the Windows PR-diff audit. Those exact variants are excluded
consistently; other mutations in the same methods remain selected.
**Linux `wake_condition_all` deletion is intentionally excluded in the
current configuration**, after the Ubuntu probe reproduced its hang. The
older b7f9278 audit had retained it; that historical result must not be
read as the current selection.
Mutation timeouts still fail the check. Excluded hangs are not counted
as caught, normal tests and assertions remain, and neither caches nor
the remaining Miri checks are bypassed.
## Verification for the review follow-up
- Anvil formatting, full workspace Clippy, README regeneration, spelling
and manifest checks passed.
- Windows: 393 selected all-feature tests passed (389 Performables,
three Arty worker-guard cases and the recorder-lifecycle fixture). The
isolated Performables no-default suite passed all 377 tests. The final
clock-helper cleanup was followed by another successful 389-test
all-feature run and debug/release Performables/Arty builds.
- Focused Anvil Miri passed six notification protocol tests and four
portable ownership/poison/wakeup tests. This is not a new complete Miri
sweep.
- Criterion test mode executed all three one-worker watch read/clone
controls successfully. Optimized ready-benchmark IR before/after hint
removal showed no added calls through the removed Performables helper
boundaries on this Windows target. These checks are not fresh
comparative timings.
- Explicit telemetry-test selection without seismograph now rejects the
command with Cargo's missing-feature diagnostic, rather than reporting
an empty successful run.
- The Windows wake-removal audit ran 20 mutants: 12 caught, eight
timeouts. The Ubuntu audit ran 14: 13 caught, one timeout.
- The broader Windows PR-diff audit ran 428 mutants in 32 minutes: 183
caught, 215 unviable, 28 timeouts and two missed test-clock expressions.
The clock expressions were moved outside mutation-selected production
bodies; the recorded non-terminating variants were narrowly excluded.
- The final Windows PR-diff enumeration for that follow-up retained 397
identities, every one matched to a previously caught or unviable
identity. Both retained cancellation and finite-timeout faults were
rerun and caught. **This historical selection audit is not a completed
mutation run for the later base integrations.**
Earlier integrated-source checks also passed broad Windows/Ubuntu
suites, optimized Performables/Arty/Tick suites, doctests and all 51
ready instruction-count benchmark cases. The earlier allocation probe
reported zero allocations/bytes for warmed operations, excluding an
unmatched empty Tokio control that has since been removed.
## Subsequent integration and CI repair
The branch incorporates main's native monitor transport and Arty
I/O-driver integration. Worker signaling keeps Notify while retaining
the driver-interrupt waker and pending-notification consumption required
by the new I/O wait path.
CI on **c7724c1a** exposed a benchmark-only dependency cycle, a missed
close-telemetry mutation, a mixed-contention test completion timeout,
and an I/O test requesting three processors on two-processor external
runners. **37b22763** makes six narrowly scoped file changes:
- Remove `performables`' Tick dev-dependency and use a standard
monotonic benchmark timer over the existing barrier interval. Library
timing APIs and benchmark workload cases remain unchanged.
- Keep the watch allocation live throughout the telemetry fixture and
require exactly one close event for its object and thread. This prevents
recycled channel addresses from satisfying the wrong assertion. The
exact previously missed receiver-drop subtraction-to-addition mutant is
now caught; no mutation exclusion was added.
- Keep four mixed reader/writer roles, yield placement, coherence
assertions, exact final count and the five-second liveness watchdog,
while reducing redundant native repetitions from 2,000 to 64. Miri keeps
its existing eight repetitions. The original workload passed 100
instrumented local runs before this reduction; no production lock change
or coverage exclusion is claimed.
- Run the three-worker I/O failure scenario only when three processors
are available, matching existing hardware-capability guards. Its
complete assertions remain active on capable hosts; the other I/O
scenarios still run on two-processor runners.
Local verification for this repair passed the Anvil quality gates
including dependency-cycle detection, 790 affected all-feature native
tests, 377 isolated no-default-feature Performables tests, all 25
instrumented synchronization-mode tests, the focused release I/O
regression, all host-selected watch benchmark smoke cases, and
debug/release builds. The single missed mutation was rerun and caught.
Optional external SARIF/SBOM publication-evidence diagnostics were not
bypassed or patched into this performance change.
No public API, production synchronization code, coverage threshold,
mutation configuration, cache or required check was changed by that
repair. Those results describe the historical **37b22763** repair, not
the latest PR head.
### Latest base refresh and lint repair
The branch includes main through **11d82cff**, including the repository
agent policies and socket-address ThreadAware implementations. The
rebased tree matched an independent clean merge result before the
following test-only repair.
Azure build **43040594** passed all **10,086 Linux native tests** and
completed its doctests. Its Linux development job failed afterward
because Clippy 1.97 treated the `PublishOnDrop` test helper as a
replaceable no-op waker. **dc2bee8a** keeps publication in `Drop` and
rejects an unexpected wake. The cleanup behavior and existing assertions
remain unchanged. No lint suppression or coverage exclusion was added.
The rebased source passed 822 selected all-feature native tests, three
no-default-feature ThreadAware-core tests, the selected doctests, and
debug/release all-target builds. After the fixture repair, Clippy passed
on both Rust 1.95 and 1.97. All 11 watch-contention tests passed with
all features and again without default features. Anvil formatting,
workspace Clippy, README regeneration and spelling passed, as did the
scoped debug/release builds.
Follow-up **2f6de79a** adds a compile-time power-of-two check for the
existing shard bitmask and completes the same drop-only fixture repair
for Notify and queues. It preserves the eight-shard layout, cleanup
callbacks, all existing assertions, and public APIs. The two benchmark
lifetime comments required no code changes: Rust 1.95 defines
`Waker::noop()` as returning `&'static Waker`, and the exact uncontended
benchmark check passed.
For that follow-up, the full standard Anvil Clippy check passed before
the final two fixture edits. The changed targets then passed Clippy
1.95, and the entire Performables package passed all-target Clippy 1.97
with warnings denied. All 390 all-feature tests passed with one existing
skip, and all 377 no-default-feature tests passed. Debug/release
all-target builds, formatting, README regeneration and spelling passed.
No coverage or mutation exclusions were added.
Fresh required CI must validate the latest pushed head. No new complete
remote coverage or mutation result is claimed for that head.
No fresh final-head 176-core timing or complete local PR tier is
claimed. Required CI remains authoritative for the latest pushed head.
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8bda2a0b-7dbf-4d57-a10b-456b744da539
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
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.
Motivation
Blocking channel operations and async-capable barrier waits allocate a thread waker even when they can finish immediately. This adds avoidable allocation and latency to ready operations, unlike the existing uncontended mutex and reader-writer-lock fast paths.
Approach
ready_blocking_allocations.rs.No public API changes relative to current
main. Base integration retainsmain's crate-rootError,sync::{Async, Sync}, andBarrierWaitOutcomeAPIs from #820. Queue payload storage and enabled telemetry may allocate independently. Final async-capable barrier arrivals avoid allocating their own waiter storage; this does not promise allocation-free release of other waiters. Pending operations retain their existing blocking and cancellation behavior.Benchmark comparison
Compared against unmodified
mainat131f7d6a, with identical benchmark source, Rust 1.95, all features, fat LTO, and one logical CPU on Windows x64 / AMD Ryzen 7 PRO 7840U. Ran baseline/optimized/optimized/baseline, with 100 samples, 1-second warm-up and 2-second measurement per case. Values average the two independent-run medians. Before/after 95% confidence intervals remained separated across both repeats for every case.Measurements were taken at original commit
b3d78d3(replayed as6f4830e6), before later naming, documentation, test-only follow-ups, and base integrations. Reported benchmark identities and measured operations remain unchanged; synchronization type paths were adapted to #820. These timings were not rerun after the follow-ups, rebase, or merges.These are already-ready microbenchmarks, not contended throughput or end-to-end application speedups. Independent allocation tests reproduce one thread-waker allocation per ready call before the change and zero afterward, with queue payload storage prepared outside measurement.
Base integration and CI corrections
Current head
676aeeccmergesmainatf660d7c6. The sole textual conflict was in Arty's worker-wait regression, where #843 independently introduced a fuller deterministic-cleanup fix. The merge retains upstream's public cancellation test and private consuming-stop regressions, including all shutdown-completion joins, and removes this branch's superseded duplicate. Arty is now identical tomain; the PR is back to a 12-file diff. The optimization, allocator and Seismograph files are unchanged from the previously passing head627e1f59. The lockfile difference remains only theperformablesallocation-test dependency.Earlier integration preserved #820's diagnostics APIs/documentation and cargo-anvil 0.14.0 from #831. The generated crate README was regenerated, not edited by hand. The branch also includes the Quinn security fix from #816 and subsequent upstream lockfile updates; no advisory ignores were added.
Existing test defects were corrected without changing those crates' production behavior:
16f6f6f2(formerly5fb3b7dd): the allocator concurrent-publication test drains at least once before checking whether producers finished, so scheduling cannot skip its consumer loop. All original uniqueness, completeness, and tail-retention assertions remain.ec8c2569(formerly84acafd8): the Seismograph clear-buffer test distinguishes active allocation reuse from valid retired-thread cleanup. An explicit retired-thread fixture reproduced the old failure deterministically: total allocation fell from 37264 to 18832 bytes, the same 18432-byte difference seen in CI. The corrected test checks active ring allocation identity/capacity across enabled/disabled clear, exact policies and event counts, and actual retired-ring release. Fallible statistics prevent observation errors from appearing as empty results.62e0073b(formerly75fae2ab) gives the fixtures safely owned process-lifetime references, removing both new pointer dereferences reported by CodeQL without suppressing or dismissing alerts.The Windows Miri shutdown failure led to
627e1f59: nested runtime owners consumed on an async worker correctly request shutdown without waiting, so the regression needed retained completion handles and off-worker joins. That implementation is now superseded by the equivalent, broader upstream #843 tests, not dropped without replacement. No production runtime behavior or public API was changed by that follow-up.d7f12241(formerlya7b9fff0) addresses documentation/readability feedback with concise contracts, generated README updates, and worker-local handle ownership. All 14 threads from that review and both later CodeQL threads were replied to and resolved. Watchdogs and mutation cases remain enabled; no requested exclusions or watchdog disabling were introduced.Validation
Latest integration (
676aeecc)just anvil-clippypasses, as does explicit Rust 1.95 all-feature/all-target Clippy for arty, arty_executor, performables, rallocator and seismograph. The earlier local Spectre-library prerequisite blocker is no longer present in this validation.676aeecc; passing checks on627e1f59do not establish current-head success.Earlier measured evidence (not rerun on the latest merge)
Exact Windows source coverage was measured after the prior semantic merge at
a1d069ce, with zero raw uncovered LCOV source lines in both feature configurations:Arty was measured at 1563/1563 after
627e1f59; subsequent upstream lifecycle refactoring changes its source inventory, so that historical total is not a current Arty coverage claim. Linux coverage passed at 100% before the base integrations and must be reconfirmed by fresh CI. No fresh complete local Anvil PR-tier success is claimed.Both channel and barrier unit-test modules use
#[cfg_attr(coverage_nightly, coverage(off))]for test-harness code; their tests and assertions still execute, and their exercised production paths remain measured. The latest conflict resolution adds no coverage or mutation exclusions relative to currentmain.try_changed -> Nonereplacement remains enabled and was caught. The latest merge leaves all PR-specific production changes unchanged; no fresh complete mutation campaign is claimed for this merge.CI success does not imply approval or merge.