Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Nov 8, 2025

thesis is, that we need less memory when processing big projects

in phpstan-src I can see the coverage producing test-runs to consume ~3GB of data.
my gut feeling is, that if we would consume less data we would automatically get faster, because we need less memory allocations


running phpstan-src@8f9490ecc6

before this PR (37047b5):

➜  phpstan-src git:(2.1.x) ✗ XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-xml=tmp/coverage-xml tests/PHPStan/Type/Constant --path-coverage
PHPUnit 12.4.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.27 with Xdebug 3.4.7
Configuration: /Users/staabm/workspace/phpstan-src/phpunit.xml

...............................................................  63 / 128 ( 49%)
............................................................... 126 / 128 ( 98%)
..                                                              128 / 128 (100%)

Time: 01:18.247, Memory: 1.18 GB

OK (128 tests, 209 assertions)

Generating code coverage report in PHPUnit XML format ... done [00:05.877]

with this PR (1b73b3c)

➜  phpstan-src git:(2.1.x) ✗ XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-xml=tmp/coverage-xml tests/PHPStan/Type/Constant --path-coverage
PHPUnit 12.4.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.27 with Xdebug 3.4.7
Configuration: /Users/staabm/workspace/phpstan-src/phpunit.xml

...............................................................  63 / 128 ( 49%)
............................................................... 126 / 128 ( 98%)
..                                                              128 / 128 (100%)

Time: 00:53.183, Memory: 1.18 GB

OK (128 tests, 209 assertions)

Generating code coverage report in PHPUnit XML format ... done [00:05.709]

@sebastianbergmann
Copy link
Owner

Is the only reason you're still considering this a draft/proof of concept because the tests need updating?

@staabm
Copy link
Contributor Author

staabm commented Nov 9, 2025

draft/proof of concept because the tests need updating?

yes

@staabm staabm changed the title POC: Represent CoverageData in objects Represent CoverageData in objects Nov 9, 2025
@codecov
Copy link

codecov bot commented Nov 9, 2025

Codecov Report

❌ Patch coverage is 88.80000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.98%. Comparing base (37047b5) to head (43206aa).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/Node/File.php 60.00% 8 Missing ⚠️
src/Report/Html/Renderer/File.php 78.26% 5 Missing ⚠️
src/Data/ProcessedFunctionCoverageData.php 97.14% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1105      +/-   ##
============================================
+ Coverage     88.82%   88.98%   +0.15%     
- Complexity     1391     1408      +17     
============================================
  Files            98      101       +3     
  Lines          4655     4712      +57     
============================================
+ Hits           4135     4193      +58     
+ Misses          520      519       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@staabm staabm marked this pull request as ready for review November 9, 2025 17:17
@staabm staabm marked this pull request as draft November 9, 2025 17:28
@staabm
Copy link
Contributor Author

staabm commented Nov 9, 2025

tested a different case on the phpstan-src codebase:

running phpstan-src@8f9490ecc6

before this PR (37047b5):

➜  phpstan-src git:(2.1.x) ✗ XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-xml=tmp/coverage-xml tests/PHPStan/Reflection/Annotations --path-coverage
PHPUnit 12.4.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.27 with Xdebug 3.4.7
Configuration: /Users/staabm/workspace/phpstan-src/phpunit.xml

......................................S^[[C..S...............         57 / 57 (100%)

Time: 06:09.856, Memory: 1.23 GB

OK, but some tests were skipped!
Tests: 57, Assertions: 1985, Skipped: 2.

Generating code coverage report in PHPUnit XML format ... done [00:05.955]

with this PR (3e53a48)

➜  phpstan-src git:(2.1.x) ✗ XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-xml=tmp/coverage-xml tests/PHPStan/Reflection/Annotations --path-coverage
PHPUnit 12.4.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.27 with Xdebug 3.4.7
Configuration: /Users/staabm/workspace/phpstan-src/phpunit.xml

......................................S..S...............         57 / 57 (100%)

Time: 03:58.814, Memory: 1.31 GB

OK, but some tests were skipped!
Tests: 57, Assertions: 1985, Skipped: 2.

Generating code coverage report in PHPUnit XML format ... done [00:05.869]

@staabm staabm marked this pull request as ready for review November 9, 2025 18:13
@staabm
Copy link
Contributor Author

staabm commented Nov 9, 2025

After a few more tests, I think the optimization is only substantial when phpunit is invoked with --path-coverage

@staabm
Copy link
Contributor Author

staabm commented Nov 9, 2025

I think we can achieve similar things for regular line-coverage.. will prepare a separate PR

@staabm staabm marked this pull request as draft November 10, 2025 08:56
@staabm staabm marked this pull request as ready for review November 10, 2025 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants