Skip to content

[lld][EVM] Assemble and link EVM objects on one thread - #208

Merged
hedgar2017 merged 1 commit into
mainfrom
perf/lld-single-thread-link
Oct 27, 2026
Merged

hedgar2017 merged 1 commit into
mainfrom
perf/lld-single-thread-link

Conversation

@hedgar2017

Copy link
Copy Markdown
Contributor

LLVMAssembleEVM and LLVMLinkEVM run lld with --threads=1. Each call handles one object of a few kilobytes, and lld's default thread pool costs more per call than the link itself: spawning the task group and waiting on its condition variables was the largest item in a sample profile of the two calls.

Benchmark, measured through the compiler that calls these two entry points once per object: Apple M2 Max (12 cores, 64 GB), macOS 27.0.1, RelWithDebInfo, 12 threads, one warm-up then 5 runs, medians, bytecode byte-identical.

input objects assemble+link before after compile wall before after
ENS 62 25.4 ms 11.7 ms 519 ms 506 ms
uniswap-v4-core 260 132 ms 69 ms 1656 ms 1584 ms
OpenZeppelin 1110 436 ms 192 ms 3836 ms 3555 ms
one contract 2 1.53 ms 0.82 ms 25.2 ms 24.9 ms

Before the change the per-object cost was 0.22 ms to assemble and 0.14 ms to link regardless of the object's size.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

✅ With the latest revision this PR passed the C/C++ code formatter.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The threading setting persists globally after either call and can serialize unrelated subsequent LLVM work.

1 open issue
What changed in this PR

Reduces lld overhead for small EVM objects handled by the C library entry points.

Changes:

  • Adds --threads=1 to EVM assembly and linking.
  • Documents why serial execution is preferred for these inputs.
File Description
lld/​lld-c/​LLDAsLibraryC.cpp Configures both EVM entry points to use single-threaded linking.

Review effort: Balanced

Comment thread lld/lld-c/LLDAsLibraryC.cpp Resolved
@hedgar2017 hedgar2017 self-assigned this Oct 20, 2026
@hedgar2017
hedgar2017 marked this pull request as ready for review October 20, 2026 17:00

@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!

Please, address the formatting message.

@hedgar2017
hedgar2017 force-pushed the perf/lld-single-thread-link branch from 5213349 to 331227c Compare October 27, 2026 08:42
@hedgar2017
hedgar2017 force-pushed the perf/lld-single-thread-link branch from 331227c to ddf68f9 Compare October 27, 2026 11:01
@hedgar2017
hedgar2017 merged commit 18cbba6 into main Oct 27, 2026
4 checks passed
@hedgar2017
hedgar2017 deleted the perf/lld-single-thread-link branch October 27, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants