Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve batch copy performance #3483

Merged
merged 52 commits into from
Jul 15, 2023

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jun 8, 2023

per cancun, eip-5656. also add heuristics to use loops vs unrolled loops for batch copies.

bytecode size comes down roughly 2-5%, i checked curve-stablecoin/Stableswap.vy, tricrypto-ng/TriCryptoOptimizedWETH.vy and vaults/VaultV3.vy. there are potentially more places where we could use copy_bytes too

What I did

How I did it

How to verify it

Commit message

per cancun, eip-5656, this commit adds the use of mcopy for memory
copies. it also
- adds heuristics to use loops vs unrolled loops for batch copies.
- adds helper functions `vyper.codegen.core._opt_[gas,codesize,none]()`
  to detect optimization mode during codegen
- adds `--optimize none` to CLI options, with the intent of phasing out
  `--no-optimize` if the ergonomics are better.

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov-commenter
Copy link

codecov-commenter commented Jun 8, 2023

Codecov Report

Merging #3483 (1c64f2c) into master (593c9b8) will increase coverage by 0.01%.
The diff coverage is 93.18%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #3483      +/-   ##
==========================================
+ Coverage   89.17%   89.19%   +0.01%     
==========================================
  Files          84       84              
  Lines       10882    10948      +66     
  Branches     2488     2503      +15     
==========================================
+ Hits         9704     9765      +61     
- Misses        767      771       +4     
- Partials      411      412       +1     
Impacted Files Coverage Δ
vyper/evm/opcodes.py 100.00% <ø> (ø)
vyper/ir/compile_ir.py 93.76% <ø> (ø)
vyper/codegen/ir_node.py 91.24% <83.33%> (+0.05%) ⬆️
vyper/codegen/core.py 87.41% <93.10%> (+0.47%) ⬆️
vyper/ir/optimizer.py 97.95% <94.44%> (-0.24%) ⬇️
vyper/cli/vyper_compile.py 64.18% <100.00%> (ø)
vyper/compiler/phases.py 92.36% <100.00%> (+0.11%) ⬆️
vyper/utils.py 84.15% <100.00%> (-0.08%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

this commit adds the `--optimize` flag to the vyper cli, and as an
option in vyper json. it is to be used separately from the
`--no-optimize` flag. this commit does not actually add different
options, just adds the flag and threads it through the codebase so it is
available once we want to start differentiating between the two modes,
and sets up the test harness to test both modes.
note: mypy needed bump to 0.940 to handle match/case
it was probably important when we supported pre-constantinople targets,
not anymore
it passes in no-opt mode now as well
@charles-cooper charles-cooper changed the title feat: use mcopy for copy bytes feat: improve batch copy performance Jul 14, 2023
@charles-cooper charles-cooper enabled auto-merge (squash) July 15, 2023 14:52
@charles-cooper charles-cooper merged commit 5dc3ac7 into vyperlang:master Jul 15, 2023
75 of 76 checks passed
tests/compiler/test_opcodes.py Show resolved Hide resolved
vyper/evm/opcodes.py Show resolved Hide resolved
tests/compiler/test_opcodes.py Show resolved Hide resolved
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.

None yet

4 participants