perf: Reuse the QueryBuilder ObjectType - #779
Draft
realFlowControl wants to merge 3 commits into
Draft
Conversation
Create the QueryBuilder ObjectType once in the resolver constructor and reuse it for return-type compatibility checks. The resolver is called more than 600,000 times in the measured workload. The ObjectType is immutable for this use, so allocating the same value for each method candidate only adds allocation and CPU overhead. Benchmark: uncached Sylius analysis of 2,366 files with eight workers, five runs per variant. Median elapsed time fell from 28.91 s to 28.34 s (-2.0%) and aggregate user+sys CPU from 176.22 s to 169.68 s (-3.7%).
Contributor
Author
|
I do not fully understand why infection still fails, something is off |
Contributor
|
we don't necessarily need a green mutation testing build on each PR though |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Create the
QueryBuilderObjectTypeonce in the resolver constructor and reuse it for return-type compatibility checks.The resolver is called more than 600,000 times in the measured workload. The
ObjectTypeis immutable for this use, so allocating the same value for each method candidate only adds allocation and CPU overhead.Benchmark: uncached Sylius analysis of 2,366 files with eight workers, five runs per variant. Median elapsed time fell from 28.91 s to 28.34 s (-2.0%) and aggregate user+sys CPU from 176.22 s to 169.68 s (-3.7%).
Benchmark run locally using PHPStan 2.2.x and PHPStan-Doctrine 2.0.x on MacOS with PHP 8.5.7