fix(gatsby): Use shared gql runner in PQR workers #32355
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Previously, every worker and its
runQueries
call initiated anew GraphQLRunner()
call which was quite expensive time and memory wise. The problem with that is that it basically resets all fast filters cache on each chunk. It means in turn that we need to re-visit all nodes of a type on each chunk which could be pretty slow on big datasets.So with this change it's not created every time 😆
In some tests (although not super representative as memory inside WSL2 is a bit weird and other stuff was running) this yielded these results:
With
GATSBY_CPU_COUNT=7 NUM_NODES=150000 NUM_PAGES=10000 FILTER=eq-uniq yarn bench --verbose
:Before: ~10GB RAM and 14s with 696 queries/s
After: ~2.5GB RAM and 3s with 3200 queries/s
Related Issues
[ch34193]