Repository navigation
Conversation
staabm
reviewed
Nov 10, 2026
| ); | ||
| } | ||
|
|
||
| public function testIdenticalArrayDoesNotCompareItsValues(): void |
Contributor
There was a problem hiding this comment.
instead of a mock based test which relies on implementation details, it would be great to have a file when analysed before/after this change shows a meaningful speed improvement
Author
There was a problem hiding this comment.
The tests/bench/data/bug-7903.php case already works as a good example for this improvement, for now i decided to use that case as benchmark and decrease the accepted perf threshholds on that case
happy to create a new dedicated benchmark case when you prefer that
Contributor
There was a problem hiding this comment.
I can see instruction counts beeing reduced in the benchmarks for some cases. I am not able to reproduce a time-wise performance improvement when running these benchmark on its own so...
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.
ConstantArrayType::isSuperTypeOf()recursively compares keys and values even when its argument is the exact same type object.Return
yesimmediately for that case in both PHP and PHPStan Turbo.This avoids repeated traversal of large nested shapes without changing the result for distinct operands.
The existing standalone bug-7903.php benchmark exercises this during loop-scope merges of shared nested array templates.
Its expected metrics are refreshed from the benchmark-measured CI artifact.
The implementation-specific mock test is removed.
The committed instruction baseline was 7,793,234,919; the optimized CI measurement is 6,358,641,712, a reduction of 18.4%.
Against the refreshed expectation, the previous count is 22.6% slower and exceeds the existing 20% regression tolerance.
All 93 measured CI benchmarks pass against the updated expectations.
Controlled full-CLI measurements on PHP 8.4.15 alternate before/after order, with only the identity shortcut changed in the backend being measured.
OPcache settings are identical, JIT is disabled, result-cache reuse is disabled with
--debug, and both Turbo variants are built with the same compiler flags.Each run verifies normal Turbo activation, including its enabled type-combination cache.
The median paired reduction is 6.8% for PHP and 0.4% for Turbo.
This fixture demonstrates a repeatable elapsed-time reduction in PHP; the Turbo difference is within observed timing variation and does not demonstrate a meaningful full-CLI speedup.
The earlier analysis-only Turbo timing claim is withdrawn: direct native-class activation bypassed the normal type-combination cache, so that measurement did not represent normal Turbo operation.
All 96 measured CLI runs report zero diagnostics.
The command shape used for each variant is:
Measurement configuration adds a runtime-verification bootstrap and gives each variant a separate temporary directory.
The complete
ConstantArrayTypeTestpasses in PHP and Turbo (196 tests, 254 assertions each).The native baseline builds with strict compiler warnings, and the changed test passes upstream's coding standard.
This optimization is independent of array-shape preservation and does not change the complexity budget.
Related analysis and independently scoped changes: twigstan/twigstan#317.