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
Constructing and forcing a fresh LazyCell with an immediately ready initializer took 314 ms for seven million cells. This measures the first shared force_pin on each cell. The peer starts with a stored future, while LazyCell::new starts with a factory that produces one.
Apple M4 Max, macOS arm64, rustc 1.101.0-nightly. Each cell gives rank, elapsed time relative to Asyncband and the whole-batch median over 10 interleaved runs. Lower is faster. Supplemental measurements
force_pin locks the initializer state and drives the stored future before publishing its value. The macOS allocation probe observed one 64-byte allocation per fresh Asyncband cell and zero for async-once-cell. A separate run with only the internal lock switched to parking_lot took 135 ms versus 339 ms for the original, with the peer at 67 ms.
First contribution
Compare LazyCell::new with LazyCell::from_future using the same immediately ready value and fixed round count. Measure forcing an already initialized cell separately. For a change to shared initialization, verify that a second caller resumes the same pinned future after the first caller cancels, and that a panicking initializer still poisons the cell.
To run the supplemental peer_checks command below, save and run peer-checks.rb from the linked comment in a disposable checkout of 6102089. The benchmark and library sources match 36ba6f2. Generator and instructions
Could you assign this to me? I'd compare LazyCell::new and LazyCell::from_future on an Apple M4 (10 cores, macOS 27.0.1), and measure forcing an initialized cell separately.
force_pin goes through the async Mutex, whose guard calls release_with_lock, so I expect the 64-byte allocation comes from the first lock of waiters on macOS. Since #406 skips that lock when uncontended, I'd measure with and without it before proposing a change here.
I haven't run these yet. I used Claude to help me read the code.
Reproduced on Apple M5 (10 cores), macOS 27.0.1, rustc 1.99.1 stable, in a disposable checkout of b1354ae (current main; for calibration against the issue's 6102089, note that #394's acquisition-future shrink and #412's OnceCell uncontended-init fix are in this tree — #412 touches once/once_cell, not LazyCell). Median of ten interleaved repetitions, min..max ranges, via the PR #383peer-checks.rb generator.
Scenario
Rounds
Asyncband
async-once-cell
Construct and force once
7,000,000
247 ms (238..273)
66 ms (64..72)
The gap is 247/66 = 3.7x on this host (314/67 = 4.7x on the issue's M4 Max table).
Probe (a #[global_allocator] counter plus wall-clock over 1,000,000 rounds per window; the windows ran sequentially in one pass, so cross-window timing comparisons are indicative only; the initializer is immediately ready, matching the issue's protocol, using std::future::ready because force requires Fut: Unpin):
Window
Allocations per round
Bytes per round
Time
new + first force
1
64
71.5 ms
from_future + first force
1
64
36.2 ms
force, already initialized
0
0
4.3 ms
Both constructors show the same allocation profile: exactly one 64 B allocation per round in each window (1,000,000 allocations across 1,000,000 rounds in both). The from_future window's timing matches the bench row's rate (247 ms per 7 M ≈ 35 ms per 1 M); the earlier new window is slower, and a single sequential pass cannot separate constructor shape from window order. Forcing an already-initialized cell allocates nothing and runs at 4.3 ms per 1 M, against the bench's first-force rate of ≈ 35 ms per 1 M.
The first three allocations of the new window captured backtraces, and all three are identical: std::sys::sync::once_box::OnceBox<pthread::Mutex>::initialize reached through asyncband::internal::semaphore::Semaphore::release_with_lock — the internal semaphore mutex's lazy pthread boxing at the first force's first lock, the same Darwin-platform site documented in #400 and #398.
Activity
rokadepiyush49-rgb commentedon Nov 6, 2026
Could you assign this to me? I'd compare
LazyCell::newandLazyCell::from_futureon an Apple M4 (10 cores, macOS 27.0.1), and measure forcing an initialized cell separately.force_pingoes through the asyncMutex, whose guard callsrelease_with_lock, so I expect the 64-byte allocation comes from the first lock ofwaiterson macOS. Since #406 skips that lock when uncontended, I'd measure with and without it before proposing a change here.I haven't run these yet. I used Claude to help me read the code.
tisonkun commentedon Nov 6, 2026
Thanks for your interest! We don't assign issues to individual contributors. Anyone is welcome to submit a PR directly for review.
nanami-0713 commentedon Nov 10, 2026
Reproduced on Apple M5 (10 cores), macOS 27.0.1, rustc 1.99.1 stable, in a disposable checkout of
b1354ae(current main; for calibration against the issue's6102089, note that #394's acquisition-future shrink and #412's OnceCell uncontended-init fix are in this tree — #412 touchesonce/once_cell, notLazyCell). Median of ten interleaved repetitions, min..max ranges, via the PR #383peer-checks.rbgenerator.The gap is 247/66 = 3.7x on this host (314/67 = 4.7x on the issue's M4 Max table).
Probe (a
#[global_allocator]counter plus wall-clock over 1,000,000 rounds per window; the windows ran sequentially in one pass, so cross-window timing comparisons are indicative only; the initializer is immediately ready, matching the issue's protocol, usingstd::future::readybecauseforcerequiresFut: Unpin):new+ first forcefrom_future+ first forceBoth constructors show the same allocation profile: exactly one 64 B allocation per round in each window (1,000,000 allocations across 1,000,000 rounds in both). The
from_futurewindow's timing matches the bench row's rate (247 ms per 7 M ≈ 35 ms per 1 M); the earliernewwindow is slower, and a single sequential pass cannot separate constructor shape from window order. Forcing an already-initialized cell allocates nothing and runs at 4.3 ms per 1 M, against the bench's first-force rate of ≈ 35 ms per 1 M.The first three allocations of the
newwindow captured backtraces, and all three are identical:std::sys::sync::once_box::OnceBox<pthread::Mutex>::initializereached throughasyncband::internal::semaphore::Semaphore::release_with_lock— the internal semaphore mutex's lazy pthread boxing at the first force's first lock, the same Darwin-platform site documented in #400 and #398.Command used:
Performance tracking issue #396