Skip to content

refactor(linter): Remove AstKind for Argument#12525

Closed
taearls wants to merge 0 commit intooxc-project:mainfrom
taearls:07-08-refactor_ast_remove_astkind_for_argument_
Closed

refactor(linter): Remove AstKind for Argument#12525
taearls wants to merge 0 commit intooxc-project:mainfrom
taearls:07-08-refactor_ast_remove_astkind_for_argument_

Conversation

@taearls
Copy link
Contributor

@taearls taearls commented Jul 25, 2025

Part of #11490

This PR will merge into #12127

Diff between this PR and main in oxc for reference: link

Progress Checklist (updated 09/07/2025):

Before syncing with main after AstKind::SimpleAssignmentTarget was removed:

  • fix failing oxc_linter tests
  • fix performance regressions
  • sync with main after AstKind::SimpleAssignmentTarget was removed

After syncing with main (09/07/2025):

  • fix failing oxc_linter tests
  • self-review PR to minimize / simplify changes
  • exhaustive_deps.rs lint changes should be simplified
  • address formatter benchmark regressions
  • fix prettier javascript conformance tests
  • fix prettier typescript conformance tests

@github-actions github-actions bot added A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jul 25, 2025
@taearls taearls changed the title refactor(linter): Remove Argument from AstKind refactor(linter): Remove AstKind for Argument Jul 25, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 25, 2025

CodSpeed Instrumentation Performance Report

Merging #12525 will improve performances by 3.43%

Comparing taearls:07-08-refactor_ast_remove_astkind_for_argument_ (5a7cd39) with main (91c88e2)1

Summary

⚡ 1 improvement
✅ 12 untouched
⏩ 24 skipped2

Benchmarks breakdown

Benchmark BASE HEAD Change
semantic[binder.ts] 4.3 ms 4.1 ms +3.43%

Footnotes

  1. No successful run was found on main (7d45b2f) during the generation of this report, so 91c88e2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 24 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions github-actions bot added A-semantic Area - Semantic A-parser Area - Parser A-cli Area - CLI A-minifier Area - Minifier A-ast Area - AST A-transformer Area - Transformer / Transpiler A-codegen Area - Code Generation A-cfg Area - Control Flow Graph A-isolated-declarations Isolated Declarations A-ast-tools Area - AST tools A-editor Area - Editor and Language Server A-formatter Area - Formatter labels Aug 2, 2025
@taearls taearls force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from efa83e3 to d96fa0d Compare August 15, 2025 23:12
@taearls taearls force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch 4 times, most recently from 9d55b03 to 9bf000a Compare August 23, 2025 16:34
@overlookmotel
Copy link
Member

Very glad to see you're still on the case with this! Looks like it's a long hard slog. Please shout if you need any help.

@taearls
Copy link
Contributor Author

taearls commented Aug 30, 2025

Very glad to see you're still on the case with this! Looks like it's a long hard slog. Please shout if you need any help.

yes it has been pretty challenging to be honest but I'm still chipping away at it when I can!

the draft PR is most of the way there. right now I'm working on minimizing the changes that were done to the linting rules.

the main challenge at this point is getting the formatter benchmarks not to degrade. right now my short term goal is to finish everything aside from that.

in terms of performance:

My initial findings are that removing AstKind::Argument made the argument detection in the formatter turn from an O(1) operation (looking directly at the AstKind::Argument wrapping the current node being processed) to an O(n) operation (checking for span equality in the argument list of the parent).

I've tried implementing a few refactors to improve the performance, but it has either made it worse or introduced regressions in the prettier conformance tests, so I've reverted those changes on this branch.

I think I just need to find a way to reduce the redundant argument checks that currently exist on my branch, but I haven't found a solid way to do that yet.

@overlookmotel
Copy link
Member

overlookmotel commented Sep 7, 2025

Sorry I'm slow to come back to you. Have been away.

This PR has diverged a long way from the original #12127. At a time that's convenient to you, would you like to squash all the changes (including those from #12127) and rebase on latest main? That would make the diff rather easier to follow.

Maybe I'm being naive, but I don't think the perf impact should be too bad - as far as I can see, you should only need one more iteration up the ancestry chain to determine if in an Argument position or not.

I may be able to offer some pointers if I can see more clearly where you're up to (but feel free to ignore me if you don't need/want any help!)

@taearls taearls force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from a0aa11b to 888d02a Compare September 7, 2025 16:08
@taearls
Copy link
Contributor Author

taearls commented Sep 7, 2025

Sorry I'm slow to come back to you. Have been away.

This PR has diverged a long way from the original #12127. At a time that's convenient to you, would you like to squash all the changes (including those from #12127) and rebase on latest main? That would make the diff rather easier to follow.

Maybe I'm being naive, but I don't think the perf impact should be too bad - as far as I can see, you should only need one more iteration up the ancestry chain to determine if in an Argument position or not.

I may be able to offer some pointers if I can see more clearly where you're up to (but feel free to ignore me if you don't need/want any help!)

No worries at all! I understand. I appreciate you checking in.

I rebased off the latest main. The diff is quite large in this PR because it's pointed towards #12127 which I think is pretty far behind main. for now I changed the target branch on this PR to main to simplify things, but let me know if you want me to change it back! it should be much easier to see the diff now.

If you have bandwidth, I think I could use some help with the performance. I thought the same, that it would just take one iteration up the AST tree to get the argument context. I'm not sure if I may have done something silly in the formatting code changes. While patching the conformance tests between this branch and main I made some changes to the argument detection logic that may not have been the best.

I've tried a few different strategies to fix the performance, and I've learned a few things:

  • pre-allocations, even if they make performance better on my machine, make the benchmark results worse because of the memory-constrained machines that are emulated in CodSpeed
  • early returns for certain conditions (like not having arguments) helps performance but isn't enough.

@taearls taearls changed the base branch from 07-08-refactor_ast_remove_astkind_for_argument_ to main September 7, 2025 16:17
@@ -1,13 +1,42 @@
js compatibility: 645/699 (92.27%)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: need to fix these.

@@ -1,22 +1,26 @@
ts compatibility: 331/573 (57.77%)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: need to fix these.

@taearls
Copy link
Contributor Author

taearls commented Sep 7, 2025

Ok, after switching the target branch to main, the benchmarks appear to be resolved now. I probably should've done this sooner!

the only thing I'm noticing is that the prettier conformance tests have regressed a bit. once that's addressed I think this PR should be good to review. I'll start on it today

@Dunqing
Copy link
Member

Dunqing commented Sep 8, 2025

Are you already working on fixing the formatter tests? If not, leave it to me, and I will use a simple way to avoid a bunch of formatter tests from failing.

@taearls
Copy link
Contributor Author

taearls commented Sep 8, 2025

Are you already working on fixing the formatter tests? If not, leave it to me, and I will use a simple way to avoid a bunch of formatter tests from failing.

yeah, I had started working on it on a separate branch until I finished, but if you have a better way of doing it, by all means go ahead!

@taearls
Copy link
Contributor Author

taearls commented Sep 10, 2025

Are you already working on fixing the formatter tests? If not, leave it to me, and I will use a simple way to avoid a bunch of formatter tests from failing.

as an update, in my separate dev branch I have fixed the typescript conformance tests, and have 14 javascript conformance tests to go. I'm doing it on a separate branch so that I don't commit a bunch of noisy debug logs and such as I continue to iterate on it. I'm gonna keep iterating on this but lmk if you want me to push up my progress so far.

@Dunqing
Copy link
Member

Dunqing commented Sep 11, 2025

as an update, in my separate dev branch I have fixed the typescript conformance tests, and have 14 javascript conformance tests to go. I'm doing it on a separate branch so that I don't commit a bunch of noisy debug logs and such as I continue to iterate on it. I'm gonna keep iterating on this but lmk if you want me to push up my progress so far.

Great job, can you send a PR? Btw, I am cleaning up the formatter, so I am concerned this will make a lot of conflict.

@taearls
Copy link
Contributor Author

taearls commented Sep 11, 2025

as an update, in my separate dev branch I have fixed the typescript conformance tests, and have 14 javascript conformance tests to go. I'm doing it on a separate branch so that I don't commit a bunch of noisy debug logs and such as I continue to iterate on it. I'm gonna keep iterating on this but lmk if you want me to push up my progress so far.

Great job, can you send a PR? Btw, I am cleaning up the formatter, so I am concerned this will make a lot of conflict.

yes! I'll try to do that later tonight or tomorrow morning.

@overlookmotel
Copy link
Member

overlookmotel commented Sep 11, 2025

I'm doing it on a separate branch so that I don't commit a bunch of noisy debug logs and such as I continue to iterate on it.

Please don't worry about that. Not a problem. Of course, it's up to you how you want to work, but personally I think keep it simple! One PR/branch is enough...

@taearls
Copy link
Contributor Author

taearls commented Sep 12, 2025

I'm doing it on a separate branch so that I don't commit a bunch of noisy debug logs and such as I continue to iterate on it.

Please don't worry about that. Not a problem. Of course, it's up to you how you want to work, but personally I think keep it simple! One PR/branch is enough...

Yup that makes total sense. I also use the separate branch during active dev so I can guard against Claude doing anything unexpected to the branch I've got a PR attached to. My intention was to only have one PR in the end.

I'll push up my updates in the morning. There's only a few conformance tests left to fix 🙂

@overlookmotel
Copy link
Member

Please don't feel under any pressure to rush. Just to give you a heads-up: this PR is large, and from past experience changes to AstKind can be quite subtle. So it'll likely need careful review, and most of the core team are quite tied up over next few weeks. So it may take some time to get merged.

That's not to say your work isn't appreciated. It is very much. Just the timing is a bit tricky.

@taearls taearls force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from c316548 to f3bdc67 Compare September 12, 2025 15:01
@taearls
Copy link
Contributor Author

taearls commented Sep 12, 2025

pushed up my changes so far. a lot of the conformance tests are fixed. there are some snapshot updates to work through to get the CI passing again. I'll try to get to that this weekend!

@taearls
Copy link
Contributor Author

taearls commented Sep 18, 2025

I fixed the merge conflicts, but there are a lot of new CI failures now. I'm digging into it. I merged the latest from main into this branch and now the file count for the PR has exploded as well. I'll see what I can do.

@taearls taearls closed this Sep 18, 2025
@taearls taearls force-pushed the 07-08-refactor_ast_remove_astkind_for_argument_ branch from 5a7cd39 to 5ff91bc Compare September 18, 2025 17:16
@taearls
Copy link
Contributor Author

taearls commented Sep 18, 2025

ugh, crap. I did not mean to close this. one sec.

@taearls
Copy link
Contributor Author

taearls commented Sep 18, 2025

new PR here #13902. sorry about that.

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 A-cfg Area - Control Flow Graph A-cli Area - CLI A-codegen Area - Code Generation A-editor Area - Editor and Language Server A-formatter Area - Formatter A-isolated-declarations Isolated Declarations A-linter Area - Linter A-minifier Area - Minifier A-parser Area - Parser A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler 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.

3 participants