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: add optimization mode to vyper compiler #3493

Merged
merged 21 commits into from
Jul 11, 2023

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jul 7, 2023

this commit adds the --optimize flag to the vyper cli, which can take the values of "codesize" and "gas", and as an option in vyper json. it is to be used separately from the --no-optimize flag. this commit does not actually change any codegen, just adds the flag, 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.

What I did

How I did it

How to verify it

Commit message

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 change codegen,
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.

it also makes the `optimize` and `evm-version` available as source code
pragmas, and adds an additional syntax for specifying the compiler
version (`#pragma version X.Y.Z`). if the CLI / JSON options conflict
with the source code pragmas, an exception is raised.

this commit also:
* bumps mypy - it was needed to bump to 0.940 to handle match/case, and
  discovered we could bump all the way to 0.98* without breaking
  anything
* removes evm_version from bitwise op tests - it was probably important
  when we supported pre-constantinople targets, which we don't anymore

Description for the changelog

Cute Animal Picture

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

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.
@charles-cooper charles-cooper requested a review from fubuloubu July 7, 2023 01:19
vyper/compiler/settings.py Fixed Show fixed Hide fixed
@charles-cooper charles-cooper marked this pull request as draft July 7, 2023 01:50
@codecov-commenter
Copy link

codecov-commenter commented Jul 7, 2023

Codecov Report

Merging #3493 (11e678b) into master (29b02dd) will decrease coverage by 0.44%.
The diff coverage is 78.75%.

❗ 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    #3493      +/-   ##
==========================================
- Coverage   89.37%   88.94%   -0.44%     
==========================================
  Files          84       84              
  Lines       10780    10882     +102     
  Branches     2457     2488      +31     
==========================================
+ Hits         9635     9679      +44     
- Misses        749      789      +40     
- Partials      396      414      +18     
Impacted Files Coverage Δ
vyper/cli/vyper_compile.py 64.18% <28.57%> (-4.20%) ⬇️
vyper/cli/vyper_json.py 77.00% <62.50%> (-1.63%) ⬇️
vyper/ast/pre_parser.py 84.78% <68.42%> (-15.22%) ⬇️
vyper/compiler/__init__.py 88.88% <75.00%> (+0.79%) ⬆️
vyper/compiler/settings.py 88.23% <91.66%> (+8.23%) ⬆️
vyper/ast/__init__.py 100.00% <100.00%> (ø)
vyper/ast/utils.py 73.68% <100.00%> (+3.98%) ⬆️
vyper/compiler/phases.py 92.24% <100.00%> (+1.17%) ⬆️
vyper/evm/opcodes.py 100.00% <100.00%> (ø)
vyper/ir/compile_ir.py 93.76% <100.00%> (+0.01%) ⬆️

... and 4 files with indirect coverage changes

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

note: mypy needed bump to 0.940 to handle match/case
@charles-cooper charles-cooper marked this pull request as ready for review July 10, 2023 17:59
it was probably important when we supported pre-constantinople targets,
not anymore
vyper/compiler/settings.py Show resolved Hide resolved
vyper/compiler/settings.py Show resolved Hide resolved
vyper/ir/compile_ir.py Show resolved Hide resolved
@charles-cooper charles-cooper enabled auto-merge (squash) July 10, 2023 21:38
@charles-cooper charles-cooper changed the title feat: add optimization flag to vyper compiler feat: add optimization mode to vyper compiler Jul 10, 2023
@charles-cooper charles-cooper merged commit 593c9b8 into vyperlang:master Jul 11, 2023
@charles-cooper charles-cooper deleted the feat/optimize-codesize branch July 11, 2023 12:44
charles-cooper added a commit to charles-cooper/vyper that referenced this pull request Jul 12, 2023
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 change codegen,
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.

it also makes the `optimize` and `evm-version` available as source code
pragmas, and adds an additional syntax for specifying the compiler
version (`#pragma version X.Y.Z`). if the CLI / JSON options conflict
with the source code pragmas, an exception is raised.

this commit also:
* bumps mypy - it was needed to bump to 0.940 to handle match/case, and
  discovered we could bump all the way to 0.98* without breaking
  anything
* removes evm_version from bitwise op tests - it was probably important
  when we supported pre-constantinople targets, which we don't anymore
Copy link

@jacksonbinh4 jacksonbinh4 left a comment

Choose a reason for hiding this comment

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

Correction and replace please

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.

4 participants