Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak - 9 GB of RAM and 100 % processor use in 1 min, with only couple of Symfony packages #355

Closed
TomasVotruba opened this issue Feb 3, 2019 · 5 comments
Labels

Comments

@TomasVotruba
Copy link

Still the same repository to create prefixed rector.phar.
https://github.com/rectorphp/compiler

When I run bin/console compile in that repository, I have to turn off my PHPStorm and my Chrome, or the box/scoper will crash it and disable all my Chrome extensions.

render

It makes debugging very hard.

@TomasVotruba
Copy link
Author

TomasVotruba commented Feb 3, 2019

Info from Travis build

In one project I've used Travis to crawl over 500 pages in 55 minutes, but this thsi one breaks Travis.

The memory leak bubbles on mmap() function: https://travis-ci.com/rectorphp/compiler/builds/99545469#L679

It might give you a clue to solve this:

image

@TomasVotruba
Copy link
Author

TomasVotruba commented Feb 3, 2019

I just reproduced this with much less dependencies: deprecated-packages/dummy-phar#2

It will be probably something related to Symfony packages. This is composer.json:

{
    "bin": ["bin/run"],
    "require": {
        "php": "^7.1",
        "composer/xdebug-handler": "^1.3",
        "symfony/http-kernel": "^4.2",
        "symfony/console": "^4.2",
        "symfony/dependency-injection": "^4.2",
        "symfony/config": "^4.2",
        "symfony/yaml": "^4.2"
    },
    "autoload": {
        "psr-4": {
            "DummyPhar\\": "src"
        }
    }
}

@TomasVotruba TomasVotruba changed the title Possible memory leak - 9 GB of RAM and 100 % processor use in 1 min Possible memory leak - 9 GB of RAM and 100 % processor use in 1 min, wih only 4 Symfony packages Feb 3, 2019
@theofidry
Copy link
Member

I see. I can see easily 3 ways were the leak can be (in order of likeliness):

  • The parallel workers: Box is using amphp/parallel-functions to parallelise the scoping in order to make it more performant. I'm however not super familiar with the internals and it's not excluded that the package is subject to leaks.
  • PHP-Scoper: I did not observe any leak so far even on a quite sizeable codebase (several dozens of thousands of LoCs) albeit quite slow. However PHP-Scoper does not really have an extensive benchmark/performance test suite so it can be easy to introduce a leak there by mistake. I'm sure you are familiar with it but PHP-Scoper extensively use PHP-Parser and do a lot of AST manipulation, so a leak there is very easy to produce.
  • The Phar format: across the different projects to build PHARs there was always a couple of tricky points on how to build the PHAR in an efficient way and compress it without trouble. I hope I dealt with all those cases with Box but there is no guarantee.

The third case would be by far the worst one since it would likely require to tinker the Phar C extension...

Do you observe the same issue with --no-parallel and making sure that xdebug is disabled or that you are allowing box to restart the process without xdebug (box does it by default unless you have --no-restart or BOX_ALLOW_XDEBUG=1; this can be since in verbose mode)? If no then it means it's the first case, and if yes then it's a leak in PHP-Scoper

@theofidry theofidry added the bug label Feb 3, 2019
@TomasVotruba TomasVotruba changed the title Possible memory leak - 9 GB of RAM and 100 % processor use in 1 min, wih only 4 Symfony packages Possible memory leak - 9 GB of RAM and 100 % processor use in 1 min, with only couple of Symfony packages Feb 3, 2019
@theofidry
Copy link
Member

@TomasVotruba is the issue still present? PHP-Scoper should be significantly ligher (on HumbugBox master)

@TomasVotruba
Copy link
Author

I haven't tried since, so it's possibly gone. Let's close it for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants