sebastianbergmann / php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.
BSD 3-Clause "New" or "Revised" License
8.76k stars 370 forks source link

Coverage Report cache makes PHP report memory usage explode #1009

Closed Slamdunk closed 10 months ago

Slamdunk commented 10 months ago
Q A
php-code-coverage version 10.1.3
PHP version 8.2
PHPUnit version (if used) 10.3.3

Changes merged in https://github.com/sebastianbergmann/php-code-coverage/pull/1005 and released 10.1.3 made Report\PHP unusable as now it always consumes too much memory.

Our coverage.php file went from 29 Mb to 737 Mb, re-processing it with phpcov or any other tool skyrockets the memory used from < 1 Gb to > 4 Gb, with no control over it and, most important, no real benefit for the purposes of re-processing many times the Report\PHP file.

https://github.com/sebastianbergmann/php-code-coverage/pull/1005 is good because when you use many Report\*, the Directory is build only once and PHPUnit's report generation is faster, but Report\PHP should serialize the CodeCoverage object without the $this->cachedReport property filled.

I suggest the following improvements:

sebastianbergmann commented 10 months ago

All of your suggestions make sense to me, at least as short-term solutions.

Once #874 has been implemented, we should have a long-term solution.