Coverage Report cache makes PHP report memory usage explode
Slamdunk opened this issue · 1 comments
| Q | A |
|---|---|
| php-code-coverage version | 10.1.3 |
| PHP version | 8.2 |
| PHPUnit version (if used) | 10.3.3 |
Changes merged in #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.
#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:
-
Report\PHPshould serialize theCodeCoverageobject with the cache cleared using a new@internalAPI such asCodeCoverage::clearCache(different from the currently presentCodeCoverage::clearwhich has another purpose) -
PHPUnit\Runner\CodeCoverageshould generate theReport\PHPas first in the list, so that when it's processed no cache has been already built; the aforementioned APICodeCoverage::clearCachewould be practically useless, but it's still needed to ensure consistency ofphp-code-coveragepackage -
SebastianBergmann\PHPCOV\Commandshould generate theReport\PHPas first in the list for the same reason
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.