Skip to content

Perf: scan workers send back only the stubs they added (8 threads, no cache: -9 % wall, -14 % memory on a large Laravel app) - #12558

Merged
alies-dev merged 18 commits into
vimeo:masterfrom
alies-dev:alies-dev/perf-merge-compact
Nov 21, 2026
Merged

alies-dev merged 18 commits into
vimeo:masterfrom
alies-dev:alies-dev/perf-merge-compact

Conversation

@alies-dev

@alies-dev alies-dev commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

A forked scan worker sent the main process every stubbed function and constant it inherited from it, once per worker and scan round, and the main process decoded them only to keep its own. Workers now send back only the ones they added.

App, --threads=8, no cache CPU s master → PR scan s wall s peak MB issues
large private Laravel app 303.7 → 287.7 (−5.3 %) −13.1 % 77.2 → 70.1 (−9.1 %) −995 (−13.9 %) same
laravel/framework 65.1 → 64.7 (−0.6 %) −2.5 % 29.8 → 29.4 (−1.2 %) −43 (−2.6 %) same
MediaWiki 149.1 → 148.9 (−0.1 %) −1.3 % 26.0 → 25.8 (−0.7 %) −34 (−2.8 %) same
symfony/symfony 103.9 → 103.7 (−0.2 %) −1.6 % 18.5 → 18.4 (−0.5 %) −21 (−2.2 %) same¹

The gain grows with workers × scan rounds above 512 files: the Laravel app has several such rounds, the others one. With a warm cache scanning doesn't fork, and the numbers are unchanged.

M1 Pro (8 performance cores), PHP 8.5 with igbinary, median of 3 interleaved runs per cell against master a84681d. ¹ One run differs in issues that master also reports in some --threads>1 runs and not in others (HttpClientTrait.php:225, Extension.php:81).

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: unchanged

Project Memory (MB) Wall (s) Issues Weighted (types) Taint
✅ laravel 1 765 95.2 $\color{gray}{\textsf{+0.6\%}}$ 25 932 53 272 578
✅ symfony 3 623 253.5 $\color{gray}{\textsf{+0.6\%}}$ 50 626 98 643 1 438
✅ doctrine-orm 393 16.5 $\color{gray}{\textsf{+2.3\%}}$ 3 480 6 164 0
✅ psl 632 20.6 $\color{gray}{\textsf{+0.7\%}}$ 1 305 5 461 1
✅ phpunit 472 18.4 $\color{gray}{\textsf{+1.3\%}}$ 1 742 3 452 17
✅ php-parser 237 12.3 $\color{gray}{\textsf{+0.3\%}}$ 17 133 21 035 0
✅ tempest 901 31.8 $\color{gray}{\textsf{+0.2\%}}$ 5 030 10 543 221
✅ amphp-amp 62 1.9 $\color{gray}{\textsf{-1.1\%}}$ 29 49 0
✅ webmozarts-assert 286 4.2 577 2 722 0
✅ guzzle-promises 57 1.9 158 435 2
✅ monolog 154 5.2 $\color{gray}{\textsf{+0.8\%}}$ 904 2 409 10
✅ drupal 4 820 229.0 $\color{gray}{\textsf{+1.6\%}}$ 97 556 169 424 508
Total 13 402 690.4 $\color{gray}{\textsf{+0.9\%}}$ 204 472 373 609 2 775
How to read this table
  • Memory: Psalm's own peak figure, threads=1. More than +5 % fails, unless the PR changes composer.json.
  • Wall: base and head run on the same runner; ±10 % is noise. Above +20 % warns, never fails. re-run: a reversed second run was taken and the faster kept.
  • Issues: head count over all categories, then $\color{red}{\textsf{+added}}$ $\color{green}{\textsf{-removed}}$ against base.
  • Weighted (types): type issues weighted by error level (levels 1–8 as is, always-errors 10, strictness checks 1). Taint and dead-code issues are not weighed. The projects' own code is pinned and their dependencies resolve identically for base and head, so a change means Psalm reports more, fewer or differently serious issues. A rise is not necessarily a regression.
  • Taint: head count of Tainted* issues, then $\color{orange}{\textsf{+added}}$ $\color{orange}{\textsf{-removed}}$ against base. Both are orange as either direction needs review: more can be new detection or false positives, fewer can be fixed false positives or lost detection.
  • Dead code: head count of unused-code issues, shown only when a run reported some (findUnusedCode). More is red, fewer is green.
  • Total: sum over the projects compared on both sides. Thresholds apply per project, not to the total.
  • Colors: $\color{red}{\textsf{red}}$ past a fail or warn threshold (or more issues), $\color{green}{\textsf{green}}$ an improvement past noise (or fewer issues), $\color{orange}{\textsf{orange}}$ needs review, $\color{gray}{\textsf{gray}}$ noise.
  • Performance: regressed if a head run crashed or timed out or a memory or wall delta is red, else improved if one is green, else unchanged. Its icon is the check result: ❌ fail · ⚠️ warn · ✅ pass; the icon next to each project is that project's result, 💥 = not comparable: base crashed or timed out (counts as ⚠️).
  • Types (heading): direction of the total weighted change, increased · decreased · unchanged. Taint and Dead code (heading): added and removed counts, present only when non-zero. Informational, never fails the check.

head 4cbde28 · base a84681d (merge-base) · workflow run

@alies-dev
alies-dev force-pushed the alies-dev/perf-merge-compact branch from 2ebf053 to b4fdb05 Compare November 5, 2026 09:45
@alies-dev
alies-dev force-pushed the alies-dev/perf-merge-compact branch from b4fdb05 to fe28784 Compare November 8, 2026 00:40
@alies-dev

Copy link
Copy Markdown
Collaborator Author

Rebased onto master 9c011f7. No conflicts.

Re-measured on an M1 Pro, --threads=8, base = master 9c011f7, 2 runs per cell.

app mode n CPU s base Δ CPU Δ scan Δ analysis wall s base Δ wall Δ peak MB issues
private big Laravel project nocache 2 327.2 -25.8 (-7.9%) -6.6 (-15.4%) -1.6 (-5.6%) 92.8 -9.9 (-10.6%) -1359.5 (-16.1%) same
private big Laravel project warm 2 273.0 -25.6 (-9.4%) -8.4 (-27.5%) -0.7 (-2.8%) 72.3 -12.8 (-17.7%) -1446.8 (-16.1%) same
laravel-framework nocache 2 60.8 -1.0 (-1.6%) -0.5 (-6.7%) -0.1 (-0.8%) 23.8 -1.1 (-4.5%) -174.6 (-8.7%) same
laravel-framework warm 2 55.3 -1.2 (-2.1%) -0.4 (-10.8%) +0.0 (+0.4%) 19.5 -0.7 (-3.5%) -182.2 (-9.0%) same
mediawiki nocache 2 191.9 -0.7 (-0.4%) -0.5 (-5.8%) -0.1 (-0.7%) 31.4 -0.6 (-1.7%) -33.6 (-2.8%) varies
mediawiki warm 2 175.5 -0.3 (-0.2%) -0.3 (-9.8%) +0.0 (+0.0%) 26.2 -0.4 (-1.5%) -42.6 (-3.4%) varies
symfony-notaint nocache 2 94.3 -1.0 (-1.0%) -0.5 (-7.2%) -0.1 (-1.1%) 17.3 -0.6 (-3.6%) -20.9 (-2.1%) DIFF
symfony-notaint warm 2 72.4 -1.5 (-2.1%) -0.4 (-10.8%) -0.3 (-4.0%) 13.8 -0.7 (-5.3%) -29.1 (-2.9%) DIFF

DIFF on symfony-notaint is the PossiblyInvalidArgument at src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:208 that master itself reports in some --threads>1 runs and not in others; it is not caused by this PR.

@alies-dev alies-dev changed the title [7.x] Perf: shrink the results workers send to the main process Perf: shrink the results workers send to the main process Nov 8, 2026
…rge-compact

# Conflicts:
#	src/Psalm/CodeLocation.php
#	src/Psalm/Internal/Codebase/TaintFlowGraph.php
#	tests/TaintFlowGraphTest.php
…rge-compact

# Conflicts:
#	src/Psalm/CodeLocation.php
…class

Its own __serialize() and __unserialize() replace those of UnserializeMemoryUsageSuppressionTrait, so the class
no longer uses the trait. The round-trip test goes through unserialize(), as a mutation-free __unserialize() has no
effect Psalm can see when called directly.
@alies-dev

Copy link
Copy Markdown
Collaborator Author

Re-measured after merging master 0fd455b (head 58bf9db). Since the last numbers, master's #13536 already shares equal Path objects in the serialized taint graph, so this PR is down to CodeLocation serialization and the scan workers' stubs.

M1 Pro, --threads=8, base = master 0fd455b, 2 runs per cell.

app mode n CPU s base Δ CPU Δ scan Δ analysis wall s base Δ wall Δ peak MB issues
private big Laravel project nocache 2 300.7 -18.8 (-6.3%) -7.2 (-17.6%) -1.2 (-4.3%) 77.6 -9.6 (-12.3%) -994.8 (-13.9%) same
private big Laravel project warm 2 226.3 +2.9 (+1.3%) -0.4 (-2.0%) +0.7 (+2.6%) 53.8 +0.3 (+0.5%) +0.1 (+0.0%) same
laravel-framework nocache 2 61.7 -0.9 (-1.5%) -0.2 (-3.3%) -0.3 (-1.8%) 27.5 -0.7 (-2.4%) -43.6 (-2.7%) DIFF
laravel-framework warm 2 54.1 -0.1 (-0.2%) -0.2 (-5.2%) +0.1 (+0.9%) 23.7 -0.1 (-0.3%) -0.1 (-0.0%) same
mediawiki nocache 2 141.8 -0.5 (-0.4%) -0.3 (-3.8%) -0.1 (-0.6%) 25.2 -0.4 (-1.7%) -33.7 (-2.8%) same
mediawiki warm 2 122.5 -0.7 (-0.6%) -0.3 (-10.6%) -0.1 (-0.7%) 19.9 -0.5 (-2.5%) +0.0 (+0.0%) same
symfony-notaint nocache 2 101.9 -1.2 (-1.1%) -0.3 (-4.8%) -0.4 (-3.8%) 18.5 -0.7 (-4.0%) -21.0 (-2.1%) varies
symfony-notaint warm 2 74.0 +1.1 (+1.4%) -0.2 (-4.3%) +0.2 (+2.2%) 14.3 +0.1 (+0.6%) -0.1 (-0.0%) same

The gain is now in runs without a cache: with a warm cache the scan workers have little to send, and the warm deltas are within run-to-run noise (±1–2 % CPU on the M1).

DIFF on laravel-framework is one of the PR's runs missing six Mixed*/PossiblyNullReference issues in src/Illuminate/Reflection/Traits/ReflectsClosures.php:115-122. Master does the same: in 5 more runs of each, one of master's runs gave that exact result (same issue fingerprint) and all five of the PR's gave the usual one. varies on symfony-notaint is the issue count changing between runs of both master and the PR.

Its positional format saved little next to the stubs the scan workers no longer send back, and needed a field
list of its own and a cache layout bump.
@alies-dev alies-dev self-assigned this Nov 21, 2026
@alies-dev alies-dev added the release:internal The PR will be included in 'Internal changes' section of the release notes label Nov 21, 2026
@alies-dev alies-dev changed the title Perf: shrink the results workers send to the main process Perf: scan workers send back only the stubs they added (8 threads, no cache: -9 % wall, -14 % memory on a large Laravel app) Nov 21, 2026
@alies-dev
alies-dev merged commit 0b1d9ca into vimeo:master Nov 21, 2026
71 of 72 checks passed
@alies-dev
alies-dev deleted the alies-dev/perf-merge-compact branch November 21, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:internal The PR will be included in 'Internal changes' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant