Skip to content

perf(core): assemble and link objects without inner dependencies in the worker - #855

Merged
hedgar2017 merged 6 commits into
mainfrom
perf/in-worker-link
Nov 18, 2026
Merged

hedgar2017 merged 6 commits into
mainfrom
perf/in-worker-link

Conversation

@hedgar2017

@hedgar2017 hedgar2017 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Objects that depend on no other contract's object are assembled and linked by the worker that compiled them instead of in the parent's serial loop after every worker has returned; only objects that embed another contract still wait for the parent's dependency walk.

  • A runtime object is linked from itself; the deploy job carries the assembled runtime object and links from the pair. Workers receive the library addresses with the session, and a worker-linked object keeps its assembled form for any object that embeds it, which the parent drops once it has linked.
  • The new AssembleLink benchmark stage times the work in the worker.
  • solx-llvm is pinned to [lld][EVM] Assemble and link EVM objects on one thread solx-llvm#208, which links every object on one lld thread; the combined column below includes it.

Benchmark: Apple M2 Max (12 cores, 64 GB), macOS 27.0.1, 12 threads, RelWithDebInfo LLVM, one warm-up then 5 runs, medians; --standard-json on the tests/benchmark/fixtures projects, --bin -O3 on 114 single files of tests/solidity/simple. Bytecode, link references and messages byte-identical on every input in every configuration.

input wall before this change with solx-llvm#208 link in parent before this change with #208
ENS (62 objects) 519 ms 494 ms (−4.8%) 491 ms (−5.4%) 25.4 ms 4.9 ms 2.9 ms
uniswap-v4-core (260) 1656 ms 1542 ms (−6.9%) 1500 ms (−9.4%) 132 ms 49 ms 34 ms
OpenZeppelin (1110) 3836 ms 3490 ms (−9.0%) 3409 ms (−11.1%) 436 ms 10 ms 6 ms
single file, mean 25.2 ms 25.2 ms 23.7 ms (−6%) 1.53 ms 0.08 ms 0.06 ms

The parent's cost was 0.22 ms to assemble and 0.14 ms to link per object regardless of its size, so it scaled with the object count; what remains in the parent is the objects that embed other contracts. On a single file this change alone moves the work to the worker, and the lld change is what shortens the wall.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-process linking and artifact lifetimes warrant human validation, with regression coverage still needed for worker and parent paths.

1 open issue
What changed in this PR

Moves assembly and linking of self-contained objects into compiler workers, reducing serial work in the parent process.

Changes:

  • Passes library addresses and assembled runtime objects to workers.
  • Preserves assembled objects for dependent contracts.
  • Records worker assembly and linking under AssembleLink.
File Description
solx-core/​src/​project/​mod.rs Supplies linker symbols and runtime artifacts.
solx-core/​src/​project/​contract/​mod.rs Runs and profiles worker-side linking.
solx-core/​src/​process/​session.rs Shares library addresses with workers.
solx-core/​src/​process/​job.rs Carries assembled runtime bytecode.
solx-core/​src/​process/​child.rs Forwards linking inputs to compilation.
solx-core/​src/​build/​mod.rs Handles mixed object stages and parent fallback.
solx-core/​src/​build/​contract/​object.rs Tracks stages and preserves assembled artifacts.

Review effort: Balanced

Comment thread solx-core/src/project/contract/mod.rs Resolved
@hedgar2017 hedgar2017 changed the title Assemble and link objects without inner dependencies in the worker perf(core): assemble and link objects without inner dependencies in the worker Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Coverage Summary

Crate Line Coverage Function Coverage
solx 🟢 83.8% 🔴 20.0%
solx-benchmark-converter 🔴 0.0% 🔴 0.0%
solx-codegen-evm 🟡 56.6% 🟡 51.5%
solx-compiler-downloader 🔴 0.0% 🔴 0.0%
solx-core 🔴 46.5% 🟡 56.6%
solx-dev 🔴 2.2% 🔴 2.1%
solx-mlir 🔴 48.5% 🔴 48.2%
solx-slang 🔴 30.5% 🔴 34.7%
solx-solc-test-adapter 🔴 1.7% 🔴 2.1%
solx-standard-json 🔴 38.8% 🔴 42.5%
solx-tester 🔴 36.6% 🔴 34.6%
solx-utils 🔴 44.7% 🔴 45.2%
Total 🔴 13.2% 🔴 16.5%

Codecov Report | HTML Report | Workflow Run

@hedgar2017 hedgar2017 self-assigned this Oct 20, 2026
@hedgar2017
hedgar2017 requested review from a team October 20, 2026 16:29
@hedgar2017
hedgar2017 force-pushed the perf/in-worker-link branch 3 times, most recently from 0b63a1d to a7be30c Compare October 20, 2026 16:56
@hedgar2017
hedgar2017 marked this pull request as ready for review October 20, 2026 16:58
@hedgar2017 hedgar2017 added ci:sanitizer Trigger sanitizer workflow on PR ci:integration Trigger integration tests workflow on PR ci:compile-benchmark Run hyperfine compilation benchmark for this PR ci:sourcify-sweep Run Sourcify corpus on this PR labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Compile-time benchmark (--standard-json)

pr: slang v0.2.0, LLVM-based Solidity compiler for the EVM, Front end: Slang, LLVM build: b385f75d248ef6c26dd3880981f3b48096c0d879
main: slang v0.2.0, LLVM-based Solidity compiler for the EVM, Front end: Slang, LLVM build: b385f75d248ef6c26dd3880981f3b48096c0d879
prerelease: slang v0.2.0, LLVM-based Solidity compiler for the EVM, Front end: Slang, LLVM build: 716613b727e0de5b086556ca69b475aa3e496c06
runner: solx-bench-lon-1
commits: pr 0485acb6 merged into main, main 603e6737

ens-verifiable-factory-solx--solx-legacy-dwarf

binary median mean ± σ min … max vs baseline
pr 0.224 s 0.224 s ± 0.004 s 0.217 s … 0.232 s 0.994×
main 0.225 s 0.226 s ± 0.004 s 0.220 s … 0.232 s 1.000×
prerelease 0.434 s 0.433 s ± 0.007 s 0.421 s … 0.443 s 1.930×

openzeppelin-contracts-0.34--solx-legacy-dwarf

binary median mean ± σ min … max vs baseline
pr 1.608 s 1.610 s ± 0.008 s 1.601 s … 1.628 s 0.903×
main 1.780 s 1.778 s ± 0.007 s 1.769 s … 1.791 s 1.000×
prerelease 2.935 s 2.935 s ± 0.015 s 2.899 s … 2.950 s 1.649×

uniswap-v4-core-solx--solx-legacy-dwarf

binary median mean ± σ min … max vs baseline
pr 0.695 s 0.699 s ± 0.011 s 0.687 s … 0.719 s 0.954×
main 0.729 s 0.730 s ± 0.009 s 0.718 s … 0.746 s 1.000×
prerelease 1.889 s 1.884 s ± 0.026 s 1.852 s … 1.923 s 2.592×

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Sourcify sweep

  • candidate: slang (slang v0.2.0, LLVM-based Solidity compiler for the EVM, Front end: Slang, LLVM build: b385f75d248ef6c26dd3880981f3b48096c0d879)
  • reference: solx-latest (solx v0.1.8, LLVM-based Solidity compiler for the EVM, Front end: solc, LLVM build: 7d0702e169889fe4f1a2241c57bef7d2c1c68737)
  • contracts: 119117
outcome count share meaning
ok 118924 99.84% compiles: no errors and bytecode for the target source
candidate-fail 42 0.04% candidate fails, reference compiles
both-fail 151 0.13% candidate and reference both fail

Candidate-only failures (42)

kinds: error 42

count kind signature examples
42 error This contract cannot be compiled due to a combination of a memory-unsafe assembly block and a stack-too-deep error. The compiler can automatically fix the stack 10_0x33442fc10a20aad0ddd73f6ae24500f5b370dc51, 10_0x3e7b6997399ec402491c4a049e4cd727d3aa1738, 10_0x467837f44a71e3eab90aecfc995c84dc6b3cfcf7 (+39 more)

Failures shared with the reference (reference diagnostics) (151)

kinds: error 151

count kind signature examples
150 error runtime code LLVM IR generator: This contract cannot be compiled due to a combination of a memory-unsafe assembly block and a stack-too-deep error. 100_0x239d413a6ac5322d3ccaaaf43e34045bdacd7e74, 100_0x27ebdb6cefd590feaf79b20f6e77bf79dc3c04fe, 100_0x325afb837204d46a3d4158ded26a8be2681761b5 (+147 more)
1 error Member "UnexpectedInitSelector" not found or not visible after argument-dependent lookup in type(contract ParkERC1967Proxy). 56_0x69d890f783a6662e8554c8f71d1daeda1baddda2

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🧪 Integration tests — standard · PR vs main

✅ Output-preserving — bytecode size identical (28,638 comparisons), solx-tester gas identical (36,849).
✅ No new failures — Foundry's 410 failures already present on main.

Suite New failures Size Δ Gas Δ Report
solx-tester ✅ 0 ✅ 0 of 26,774 ✅ 0 of 36,849 solx-tester-report.xlsx ↓
Foundry · 26 proj ✅ 0 (410 pre-existing) ✅ 0 of 1,864 ⚪ jitter 6 of 3,303, median 0.2% (not gated) foundry-report.xlsx ↓
Hardhat · 3 proj ✅ 0 ⚪ not collected ⚪ not collected hardhat-report.xlsx ↓

Compile time — wall-clock tripwire, positive = PR slower (authoritative Δ in the compile-time benchmark comment)

Suite legacy (agg / median)
Foundry · 26 proj -2.7% / -2.7%
Hardhat · 3 proj -0.3% / +3.2%

Within noise — no suite ≥ 5%, no project ≥ 15%.

@PavelKopyl PavelKopyl left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two findings with no single line, and one proposal.

Per-iteration deep copy in the fixpoint loop (build/mod.rs:65-75). The old code's lookup map held &str -> &Object borrows; the new one clones every assembled object's full bytecode, and the loop rebuilds it on every pass — one copy of the build's bytecode per dependency level, in a PR whose point is cutting link time. The owned map is needed because assemble is &mut self now, but it can be built once outside the loop and extended after each assemble, keeping one copy total.

Comment thread solx-core/src/build/mod.rs Resolved
Comment thread solx-core/src/project/mod.rs Resolved
Comment thread solx/tests/cli/benchmarks.rs Resolved
Comment thread solx-core/src/build/mod.rs Resolved
Comment thread solx/tests/cli/metadata_hash.rs Resolved
Comment thread solx-core/src/build/mod.rs Resolved

@PavelKopyl PavelKopyl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Comment thread solx-core/src/build/mod.rs Resolved
@nebasuke
nebasuke force-pushed the perf/in-worker-link branch from 147f51b to 722243d Compare October 30, 2026 14:19
@hedgar2017
hedgar2017 added this pull request to the merge queue Nov 18, 2026
@hedgar2017
hedgar2017 removed this pull request from the merge queue due to a manual request Nov 18, 2026
@hedgar2017
hedgar2017 enabled auto-merge November 18, 2026 18:49
@hedgar2017
hedgar2017 added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 5090570 Nov 18, 2026
73 checks passed
@hedgar2017
hedgar2017 deleted the perf/in-worker-link branch November 18, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:compile-benchmark Run hyperfine compilation benchmark for this PR ci:integration Trigger integration tests workflow on PR ci:sanitizer Trigger sanitizer workflow on PR ci:sourcify-sweep Run Sourcify corpus on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants