perf(sync-service): pre-compile cached parachain runtime during relay chain fetch#3226
Closed
replghost wants to merge 4 commits intoperf/parachain-warm-skip-downloadfrom
Closed
Conversation
… chain fetch Spawn a background task to compile the cached WASM runtime immediately on parachain start, before Phase 1's relay chain head fetch. The compilation (~200-300ms) now overlaps with network I/O instead of blocking after it, removing it from the critical warm-start path.
Tests the spawn_task + oneshot pattern used for background WASM pre-compilation: - Valid WASM compiles and delivers a HostVmPrototype via oneshot - Dropped sender (cancelled task) yields cancellation error - Invalid WASM delivers compilation error through oneshot - Double-? unwrap pattern handles both error cases correctly
- Await precompiled VM before peer wait so compilation failures bail out immediately without wasting time on peer discovery - Send (HostVmPrototype, Vec<u8>) through oneshot to avoid cloning the 2+ MB runtime code bytes - Remove double_question_mark_pattern test (tests Rust, not our code) - Strip verbose comments
These tested spawn_task + oneshot behavior, not actual code.
Contributor
Author
|
Closing — benchmarks across Paseo, Polkadot, and Kusama Asset Hubs showed no measurable end-to-end improvement. Compilation (~200-300ms) is already fully hidden behind the 4-6s relay chain fetch. If relay fetch latency drops significantly in the future, a simpler approach (reorder compilation before peer wait, no spawn_task/oneshot needed) would suffice. |
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.
Summary
Changes
light-base/src/sync_service/parachain.rs: Spawnplatform.spawn_task()for WASM compilation before Phase 1, deliver(HostVmPrototype, Vec<u8>)viaoneshotchannel.try_warm_start_from_cached_codeawaits the precompiled VM before peer wait — fails fast on compilation errors without wasting time on peer discovery.A/B Benchmarks
Warm-start "para after relay" — time from relay chain ready to parachain initialized.
Baseline is #3214 (inline compilation), treatment is this PR (background precompile).
The "para after relay" metric has high variance because it includes peer discovery + Aura call proof latency which depends on network conditions. The key signal is in the sync-service timeline:
Baseline timeline (Polkadot, run 1):
Treatment timeline (Polkadot, run 1):
Compilation (~500-700ms in debug builds) runs entirely during Phase 1's ~5s relay chain fetch. The VM is ready by the time Phase 2 starts.
Relates to #3221