-
Notifications
You must be signed in to change notification settings - Fork 390
enhance(test-benchmark): use config file for fixed opcode count scenarios #1790
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
base: forks/osaka
Are you sure you want to change the base?
enhance(test-benchmark): use config file for fixed opcode count scenarios #1790
Conversation
LouisTsai-Csie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this! I left some suggestions, but I’m happy to discuss further. I’ll share this with Kamil to confirm it aligns with their needs.
|
|
||
| # Scenario configurations using test_name.*OPCODE.* patterns | ||
| # Keys are regex patterns checked in order; first match wins | ||
| SCENARIO_CONFIGS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to move this mapping into a separate file so that we can maintain it automatically with the script.
I have this prototype, here’s a quick summary of the script that helps analyze differences between the old and new mappings:
- It uses Python’s AST to analyze benchmark tests.
- It filters only tests that use the
benchmark_testwrapper with acode_generatorattribute, since we currently only support fixed-opcode-count feature in code generator. - Based on current regex conventions, identifies the patterns:
- If there is no opcode parameterization, the regex follows:
test_<opcode/precompile>_<modifier>.*(e.g.,test_selfbalance,test_codesize). - If the test is parametrized by opcode, the regex includes the opcode:
test_name.*<opcode>.*, e.g.,test_ext_account_query_warm.*<opcode>.*where<opcode>isBALANCE,EXTCODESIZE, etc. - Note: Some parametrization names should be refactored to
opcode. For example, intest_mod_arithmetic,opshould be renamed toopcodeso the script can detect it correctly.
- The script supports several modes:
checkmode: Detect new/missing entries without modifying filesdry-run: Show the generated configuration without applying changesupdate: Update the config file with new entriesno-filter: Include all benchmark tests (not needed and can be removed)
However, I suggest the following structure, and update the script accordingly:
- the opcode-count mapping under
tests/benchmark/configs/fixed_opcode_counts.py - the parser and mapping update script under
tests/benchmark/configs/parser.py
Regarding --fixed-opcode-count, I agree with the behavior this PR already had:
- If no values are passed, use the defaults from the mapping.
- If values are passed, they override the configuration for flexibility.
What do you think? Happy to discuss with different approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on our discussion yesterday, add this script into CI to make sure no cases missing.
| } | ||
|
|
||
|
|
||
| def get_opcode_counts_for_scenario( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to separate SCENARIO_CONFIGS variable and get_opcode_counts_for_scenario function in different files.
| if has_repricing: | ||
| if fixed_opcode_counts: | ||
| opcode_counts = [ | ||
| int(x.strip()) for x in fixed_opcode_counts.split(",") | ||
| opcode_counts_to_use = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This contains a few logic issues, but they will be resolved in my upcoming PR.
7ca99dc to
7c68d19
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/osaka #1790 +/- ##
============================================
Coverage 87.31% 87.31%
============================================
Files 541 541
Lines 32832 32832
Branches 3015 3015
============================================
Hits 28668 28668
Misses 3557 3557
Partials 607 607
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🗒️ Description
Follow up to #1747
Adds a python config file to allow us to use multiple differing opcodes counts for each scenario on the fly.
This PR is a WIP.
🔗 Related Issues or PRs
N/A.
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.Cute Animal Picture