Reduce worker execution allocation and copying - #3844
Merged
Merged
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a08629-2adf-73a7-a82a-7b808492226f Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a08629-cef8-70d7-8578-0361297e194c Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a08629-778c-744a-850d-820735ceaca7 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a08629-cef8-70d7-8578-0361297e194c Co-authored-by: Amp <amp@ampcode.com>
Imported the Oracle-reviewed step from the dedicated implementation orb. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d
Include matching and channel-behavior tests plus an isolated allocation benchmark. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d
Amp-Thread-ID: https://ampcode.com/threads/T-01a08629-cef8-70d7-8578-0361297e194c Co-authored-by: Amp <amp@ampcode.com>
Cover inline thresholds and persisted snapshot round trips. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d
Keep the assigned oplog index unchanged while discarding the unused cache. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d
Measure requested allocation bytes as well as counts with identical payloads and consuming-listener counts. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d
Verify identical mutation inputs and completed and incomplete replay behavior. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d
Amp-Thread-ID: https://ampcode.com/threads/T-01a08629-778c-744a-850d-820735ceaca7 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d Co-authored-by: Amp <amp@ampcode.com>
✅ Deploy Preview for golemcloud canceled.
|
Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d Co-authored-by: Amp <amp@ampcode.com>
noise64
approved these changes
Sep 11, 2026
Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a08613-7ef8-7463-a44d-1d608f77d04d Co-authored-by: Amp <amp@ampcode.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Resolves GOL-482
Summary
Reduce avoidable allocation and copying in worker execution while preserving retry, replay, ordering, authorization, and durability semantics:
Arc<Event>storage; unrelated subscribers inspect borrowed events and only matching consumers clone their result.The implementation and review follow-ups are retained as 14 separate commits. Every implementation step and the combined integration received an Oracle PASS; the final bounded bug-finder run reported no bugs found.
Measurements
An isolated event-broadcast harness compares the previous owned-event design with shared events. The harness was optimized with
-C opt-level=3(dependencies used the dev profile), counts allocations and requested bytes, and makes received events and matching cloned outputs observable withblack_box. Results were identical across three repetitions.Shared events have a fixed allocation cost: they can request more bytes for tiny payloads or zero consumers. These are allocation measurements, not end-to-end latency or fully release-optimized benchmark claims.
The 10,000-append plugin control verified no cache without delivery demand versus 10,000 cached entries with an active plugin. Debug timings are not evidence of a reliable speedup. Other copy removals are supported by source inspection and ownership/pointer-preservation tests, not runtime performance claims.
Reproduce the event measurement:
CARGO_BUILD_JOBS=4 CARGO_PROFILE_DEV_DEBUG=0 CARGO_INCREMENTAL=0 \ cargo rustc -p golem-worker-executor --profile dev \ --bench event_broadcast_allocations -- -C opt-level=3 # Execute the resulting event_broadcast_allocations binary in target/debug/deps.Local verification
services::events services::oplog services::scheduler services::blob_store: 154 passed, 0 failed.golem-worker-executor,golem-service-base, andgolem-worker-executor-test-utils, with--no-deps -Dwarnings: passed.git diff --check: passed.CI follow-up
Merged current
mainwithout rewriting the implementation commits. Initial CI exposed an upstream test initializer missed by the shard-manager leader-election change: the local-server memory-override test omitted the newRunDetails.leadershipfield. A separate one-line fix sets it toNone, matching embedded SQLite startup. Oracle reviewed that fix and returned PASS; the targeted local-server test passed.The next run passed 51 jobs and exposed an intermittent reconstruction-barrier test failure, also reproduced locally. A separate test/fixture-only fix replaces competing pre-custom HTTP checkpoints with the existing host-side entity completion gate. It explicitly establishes a completed entity and unterminated custom call at crash, then verifies repair remains blocked until reconstruction validation, proceeds after release, and writes exactly once. Oracle reviewed the actual fix and returned PASS. The rebuilt fixture and corrected test passed 11 consecutive local runs. Production durability code and test timeouts were not changed for this follow-up.
The five related tool-reconstruction tests also passed locally, and scoped integration-test Clippy passed with
-Dwarnings.Previous verified CI: PASS. Run 34377368603, attempt 2 completed successfully before the latest main update: all 52 runnable CI jobs passed, with 7 non-applicable jobs skipped. The preceding attempt was blocked by cache-service HTTP 500/404 errors during binary uploads/restores, before affected tests ran; a full workflow retry succeeded without further source changes.
Latest main update
Merged
mainagain and resolved the plugin comment and scheduler test-helper conflicts, retaining both the upstream behavior changes and GOL-482 optimizations. Oracle identified interference between the retained exact-count metric test and two new upstream Resume tests. A separate test-only commit adds a shared async mutex around those three tests without weakening their assertions. Oracle re-review: PASS.The first updated CI run exposed a missing
DbPostgresConfig.acquire_timeoutfield in the PostgreSQL scheduler test fixture. The fixture now sets it toNone, matching the test framework and preserving SQLx's default timeout. Oracle review: PASS. The corrected head passed the local scheduler/plugin filters with--nocapture --test-threads=8: 44 passed, 0 failed. Scoped executor library/test Clippy with--no-deps -Dwarnings, formatting, and diff checks also passed.Final updated CI: PASS. Run 34628100705 completed successfully: all 52 runnable jobs passed, with 7 non-applicable jobs skipped. The PostgreSQL scheduler integration test and all three Resume metric tests passed in this run. All PR checks are completed with success, neutral, or skipped conclusions; the Netlify preview status is successful. The branch includes the latest
mainand GitHub reports no merge conflicts.