infection: Infection fails with "Allowed memory size ... exhausted" for a project with a really big coverage

Question Answer
Infection version 0.13.2
Test Framework version PHPUnit
PHP version 7.2
Github Repo https://github.com/vimeo/psalm

Extracted from https://twitter.com/sorsoup/status/1140021198765658118

Infection seems to be crashing when I try to run it to check the test suite of Psalm - output at (link: https://circleci.com/gh/bdsl/psalm/232) circleci.com/gh/bdsl/psalm/…

Don’t know if I’m doing anything wrong.

Command line:

php -d memory_limit=12G ~/sites/infection/bin/infection --coverage=build/phpunit --only-covered --threads=4

Output:

     ____      ____          __  _
    /  _/___  / __/__  _____/ /_(_)___  ____
    / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
  _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
 /___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

Running initial test suite...

PHPUnit version: 7.5.12

    1 [============================] < 1 sec

Generate mutants...

Processing source code files:   0/543

PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /infection/src/TestFramework/PhpUnit/Coverage/CoverageXmlParser.php on line 170

So it fails with when the coverage data is being accumulated in the following lines of the code (depending on how much memory_limit is set

Unfortunately, code coverage takes 2+ hours for Psalm, so here is a compressed archive of needed coverage files: https://www.dropbox.com/s/66tvd0tctfbdki3/phpunit.bz?dl=0 for commit https://github.com/vimeo/psalm/commit/4c57c67e2f1b821e2ef8aa0b00448ff24ce92201

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 33 (33 by maintainers)

Commits related to this issue

Most upvoted comments

we did many changes to run Infection for big projects like Psalm, I don’t think we need to keep it open.

Really big projects can/should run Infection for a diff (modified and/or added files) only

@sanmai Yes, the direct comparison between my branch and Psalm master is https://bit.ly/2Q4LpEx . Only the circleci config file is changed. I had to re-post the comment because the permalink bot is editing the link repeatedly and getting it wrong if I don’t use bit.ly

ok, extracted to https://github.com/infection/infection/issues/1148

we also have another issue related to ocramius/package-versions that might be related https://github.com/infection/infection/issues/876

@sanmai, shouldn’t @bdsl use --no-progress & --only-covered to get the maximum of your optimizations?

I’ve created a PR with some minor changes that allowed me to run Infection for Psalm with memory_limit=12G without that fatal error.

This is not a final fix, just a few minor (but still useful) improvements.

@bdsl I’m pretty sure, you need to run Infection for Psalm only for changed files. This will dramatically reduce the mutation time. I’m not sure Infection is ready for such many mutations:

Processing source code files: 543/543
Creating mutated files and processes:    0/20516

You can see how we do it for Infection itself.

The further investigation of what is going on with coverage data is still needed, the issue is not resolved.