Skip to content

Count the benchmarks with the cycle collector off like bin/phpstan - #7083

Merged
ondrejmirtes merged 2 commits into
2.3.xfrom
tally-disable-gc
Nov 15, 2026
Merged

ondrejmirtes merged 2 commits into
2.3.xfrom
tally-disable-gc

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

bin/phpstan calls gc_disable(), so the cycle collector never runs in a real analysis, but the benchmarks ran with it on. With the collector on, whatever a benchmark's setup allocated decides whether a collection falls into the counted call.

Example: 214333e76 loads stubs/ext-ds-v2.stub when ext-ds 2 is present, as on CI. It does not touch the analysed code, yet it moved NodeScopeResolverWalkBench::benchProcessStmtNodes@or-chain-32 by +12.6 % instructions and +27 % cycles, and UnionTypeBench::benchDescribeIntersections@members-256 by −16 %. Locally, with zend.enable_gc=0, the same commit changes instructions, cycles, and memory by exactly 0.

The expected numbers are accepted from this PR's Benchmarks run.

bin/phpstan calls gc_disable(), so a collection never runs in an analysis.
With the collector on, what a benchmark's setup allocated decides whether a
collection falls into the counted call: loading one more stub file moved
NodeScopeResolverWalkBench::benchProcessStmtNodes@or-chain-32 by +15.7 % and
UnionTypeBench::benchDescribeIntersections@members-256 by -18 %, and with
zend.enable_gc=0 the same change moved nothing.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1dfe2-5bcc-770e-93fb-aeccdc327aa9
@ondrejmirtes
ondrejmirtes merged commit 02480d8 into 2.3.x Nov 15, 2026
579 of 580 checks passed
@ondrejmirtes
ondrejmirtes deleted the tally-disable-gc branch November 15, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant