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

refactor(ast, regular_expression): shorten ContentEq implementations #8519

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

overlookmotel
Copy link
Contributor

@overlookmotel overlookmotel commented Jan 15, 2025

Shorten codegen-ed implementations of ContentEq for enums, matching what Rust produces for #[derive(PartialEq)] (inspired by #8517).

@github-actions github-actions bot added A-ast Area - AST A-ast-tools Area - AST tools C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jan 15, 2025
Copy link
Contributor Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

codspeed-hq bot commented Jan 15, 2025

CodSpeed Performance Report

Merging #8519 will not alter performance

Comparing 01-15-refactor_ast_regular_expression_shorten_contenteq_implementations (30f8ec3) with main (04bc259)

Summary

✅ 32 untouched benchmarks

@overlookmotel overlookmotel force-pushed the 01-15-refactor_ast_regular_expression_shorten_contenteq_implementations branch from 1aac0ee to 30f8ec3 Compare January 15, 2025 20:31
@overlookmotel overlookmotel marked this pull request as ready for review January 15, 2025 20:31
@overlookmotel overlookmotel removed the request for review from leaysgur January 15, 2025 20:31
@overlookmotel
Copy link
Contributor Author

overlookmotel commented Jan 15, 2025

@camc314 I half-hoped this would produce a speed-up too, but no. I think ContentEq is just inherently expensive, especially when the 2 AST fragments being compared are large and mostly the same, so you have to crawl a long way through the structures to find out if they're the same or not.

But at least the code is more compact and readable using the style you suggested.

@camc314
Copy link
Contributor

camc314 commented Jan 15, 2025

thanks for looking at this.

yeah i agree. bit ast node == lots of time. can probably speed up performance by doing that minification in a later pass and running it less times.

it might be worth double checking this. but i think this approach has worse performance than before. If we consider "left" and "other", if "left" matches the first enum variant on the first thing of the match statement, and right does not, it will try ever match pattern rather than bailing out early. << this might not be correct, but it's what i understood from godbolt and some rust forums

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST A-ast-tools Area - AST tools C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants