-
Notifications
You must be signed in to change notification settings - Fork 2k
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
OverlappingFieldsCanBeMergedRule: Fix performance degradation #3958
OverlappingFieldsCanBeMergedRule: Fix performance degradation #3958
Conversation
✅ Deploy Preview for compassionate-pike-271cb3 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @graphql/graphql-js-reviewers (I can't seem to ping this list - so @martijnwalraven @Cito @yaacovCR @IvanGoncharov @saihaj) any chance we could get some eyes on this? 🙏 |
I can create a issue as this can be done in a separate PR but it's somewhat concerning this regression was possible in the first place. Would be great to have some perf tests in place. |
Hi @AaronMoat, I'm @github-actions bot happy to help you with this PR 👋 Supported commandsPlease post this commands in separate comments and only one per comment:
|
This comment has been minimized.
This comment has been minimized.
@AaronMoat Please, see benchmark results here: https://github.com/graphql/graphql-js/actions/runs/6011999302/job/16306504508#step:6:1 |
If I’m interpreting the benchmark results correctly, I am not seeing a performance improvement with this fix… |
I don't think this specific scenario is in the benchmarks. |
I guess what I’m wondering is (1) where the crossover point is, as performance seems better on main with our current tests but worse in your above scenario, and (2) whether the better mitigation is to use the maxTokens option when parsing? graphql-js/src/language/parser.ts Line 92 in b12dcff
That’s just my own 2 cents, would really love @IvanGoncharov take |
The note on maxTokens is an interesting one, noting it's linear. I'd argue this is nonlinear, even with this change. |
@AaronMoat Can you please add a benchmark to this PR otherwise this problem can reappear in the future. |
This comment has been minimized.
This comment has been minimized.
@AaronMoat Something went wrong, please check log. |
This comment has been minimized.
This comment has been minimized.
@AaronMoat Something went wrong, please check log. |
Unsure what's going on with the benchmarks; it seems to have not even got up to the new one this time. |
@AaronMoat Sorry for delay, I spend some time playing with this code and came up with 2991112 it further improves performance: It reduces memory usage by ~40%. |
@AaronMoat If you need this fix in |
Thanks @IvanGoncharov for taking that and running with it -- raised #3967 for 16.x.x |
Update(from @IvanGoncharov): In addition to reversing #3457 this PR improves performance further, see below discussion.
Resolves #3955 (at least greatly mitigates it)
Effectively reverts #3457 which introduces a performance degradation found in #3955. This pull request was identified in a git bisect. The performance issue results in the potential for DOS attacks.
I think there are potential performance increases still available in this file, but this is a simple enough fix for the immediate problem.
The following query:
now takes 564ms on my machine, and on main takes 12s.