Skip to content

compiler:remove unneccessary clone in final code gen #165

Open
Timosdev99 wants to merge 1 commit intoleanEthereum:mainfrom
Timosdev99:clone
Open

compiler:remove unneccessary clone in final code gen #165
Timosdev99 wants to merge 1 commit intoleanEthereum:mainfrom
Timosdev99:clone

Conversation

@Timosdev99
Copy link

this pr unnecessary cloning of intermediate byte code blocks and per instruction cloning during final code gen. the compiler now moves byte code block by value and processes instruction by reference

  • move intermediate_bytecode.bytecode into code_blocks instead of cloning Vec<IntermediateInstruction>
  • refactor compile_block and codegen_jump to use burrowed IntermediateInstruction/IntermediateValue rather than clone each instruction

the previous implementation duplicate the entire intermediate program and cloned every instruction inside a hot loop, causing unnecessary heap allocation

@Timosdev99 Timosdev99 changed the title remove unneccessary clone in final code gen compiler:remove unneccessary clone in final code gen Mar 15, 2026
@TomWambsgans
Copy link
Collaborator

Hi, thanks for the PR. Since the compilation performance is not currently an issue (and overall it's never a bottleneck since we need need to compile once, and then it does not impact the proving performance of the snarks), I would suggest we keep the compilation pipeline as simple as possible (even though it's already too much complex..), in particular Cloning is not an issue, and I think it's slightly simpler than std::mem::take(&mut intermediate_bytecode.bytecode). Also, after formatting, your PR does not reduce the nb of LoC, so I would suggest not to merge it for now. Does this reasoning make sense to you?

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.

2 participants