Skip to content

perf[venom]: improve CSE elimination speed #4607

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

Merged
merged 10 commits into from
May 21, 2025

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Apr 25, 2025

What I did

How I did it

How to verify it

Commit message

in the CSE elimination pass, avoid `O(n*k)` (where `n` == number of
instructions, and `k` == number of available expressions) copies
by replacing the dict with a HAMT. HAMT is an immutable dict with
`O(1)` copy (copy by reference), and `O(log N)` insert/delete/update
operations, each returning a fresh reference to a new HAMT.

we pull in the external package `immutables`, which is stable, shares
maintainership with CPython, and seems mature (receives bugfixes every
now and again, but mostly not adding new features). we pull in the
external library since HAMTs should be generally useful for the types
of lattice operations we do, and we can probably use them to optimize
other passes as well.

this commit also adds the use of `lru_cache` for some `Flag` operations
(which are bizarrely a perf hotspot)

Description for the changelog

Cute Animal Picture

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

Copy link

socket-security bot commented Apr 25, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedimmutables@​0.2110010010010080

View full report

Copy link

codecov bot commented Apr 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.81%. Comparing base (2fa2dcc) to head (d6897e7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4607      +/-   ##
==========================================
+ Coverage   92.79%   92.81%   +0.01%     
==========================================
  Files         131      131              
  Lines       18845    18858      +13     
  Branches     3274     3273       -1     
==========================================
+ Hits        17488    17503      +15     
+ Misses        928      927       -1     
+ Partials      429      428       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

for item in lattices[1:]:
tmp = res
res = _AvailableExpressions()
mt = res.exprs.mutate()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you not use with as in the add method?

Copy link
Member Author

Choose a reason for hiding this comment

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

good question, i think i just didn't like the level of nesting 😂

i think both versions do more or less the same thing though

@charles-cooper charles-cooper marked this pull request as ready for review May 2, 2025 15:52
Copy link
Collaborator

@cyberthirst cyberthirst left a comment

Choose a reason for hiding this comment

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

approved without review. with @charles-cooper we analyzed the risks of introducing the new dependency a few weeks ago and reached consensus it should be safe

@charles-cooper charles-cooper enabled auto-merge (squash) May 21, 2025 14:00
@charles-cooper charles-cooper merged commit d47ea81 into vyperlang:master May 21, 2025
159 checks passed
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.

3 participants