Skip to content

Refactor(optimizer)!: remove recursion from simplify #4988

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 7 commits into from
Apr 21, 2025

Conversation

georgesittas
Copy link
Collaborator

Saw main...toby/simplify yesterday and figured I'd try to take it to the finish line. Please take a look.

@georgesittas georgesittas changed the title Refactor!!: remove recursion from optimizer.simplify Refactor: remove recursion from optimizer.simplify Apr 17, 2025
@georgesittas georgesittas force-pushed the jo/make_simplify_iterative branch from cc5dba8 to d480c8e Compare April 17, 2025 20:25
@georgesittas georgesittas force-pushed the jo/make_simplify_iterative branch 2 times, most recently from f783593 to e01a0ba Compare April 17, 2025 21:33
@georgesittas georgesittas force-pushed the jo/make_simplify_iterative branch from e01a0ba to f08f3f7 Compare April 19, 2025 11:03
@georgesittas
Copy link
Collaborator Author

georgesittas commented Apr 21, 2025

Just a heads up: I don't think this PR will enable us to handle large ASTs without making the Expression hashing iterative, because simplify leverages hashing to detect if we reached a fixed point, which is recursive and hence a bottleneck.

I've created two branches, trying different approaches to achieve this, but both incur a performance hit compared to main and so still need to figure out how to optimize them further to at least reach parity.

EDIT: I ended up refactoring while_changing as a workaround to the above^ problem.

@georgesittas georgesittas force-pushed the jo/make_simplify_iterative branch from 80c727c to 38ec768 Compare April 21, 2025 15:10
@georgesittas georgesittas changed the title Refactor: remove recursion from optimizer.simplify Refactor!: remove recursion from optimizer.simplify Apr 21, 2025
@georgesittas georgesittas changed the title Refactor!: remove recursion from optimizer.simplify Refactor(optimizer)!: remove recursion from simplify Apr 21, 2025
@georgesittas georgesittas merged commit fb83fac into main Apr 21, 2025
6 checks passed
@georgesittas georgesittas deleted the jo/make_simplify_iterative branch April 21, 2025 18:30
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