Skip to content

compile: reuse compiled function bodies - #454

Draft
tvolk131 wants to merge 1 commit into
BlockstreamResearch:masterfrom
tvolk131:perf/shared-function-bodies
Draft

tvolk131 wants to merge 1 commit into
BlockstreamResearch:masterfrom
tvolk131:perf/shared-function-bodies

Conversation

@tvolk131

Copy link
Copy Markdown
Contributor

Repeated calls rebuild the same helper bodies, making compilation exponential for nested call graphs.

Cache bodies by AST identity within one compilation, shared across child scopes and reused by custom calls, list/array folds, and for_while. Three regression tests cover retained sharing, bytecode and runtime behavior, parameter isolation, and debug identity.

Based directly on master, with changes confined to src/compile/. Applies cleanly alongside #453; the combined library tests pass.

  • Before/after CMRs and bytecode match for p2pkh, HTLC, and kitchen-sink fixtures with debug symbols on and off.
  • Synthetic 575-byte helper chain: compilation approximately 81.5 ms → 74 µs; best of three release runs with allocation counting on an Apple M4 Pro, excluding setup and output destruction. This demonstrates scaling rather than a general contract speedup.

Draft pending hand-review.

Written with GPT 6.1 Sol on Extra High.

Written with GPT 6.1 Sol on Extra High.

This branch has not been deployed

No deployments
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.

1 participant