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

Show combined memory usage in parallel mode #2027

Merged
merged 6 commits into from
Jan 3, 2023

Conversation

janedbal
Copy link
Contributor

@janedbal janedbal commented Nov 23, 2022

Closes phpstan/phpstan#4683

Looks like this:

$ php bin/phpstan clear-result-cache -q && php bin/phpstan -v
Note: Using configuration file /usr/src/myapp/phpstan.neon.
 1486/1486 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 56 secs/56 secs

 [OK] No errors                                                                 

Took about 1.35 GB memory

src/Command/ErrorsConsoleStyle.php Outdated Show resolved Hide resolved
@@ -221,6 +227,7 @@ public function analyse(
$internalErrorsCount === 0 ? $dependencies : null,
$exportedNodes,
$reachedInternalErrorsCountLimit,
(int) array_sum($peakMemoryUsages), // not 100% correct as the peak usages of workers might not have met
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think there is a better option. Still imo much better than before. It seems working well when comparing with system memory used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested against linux ps and it gives very good results, almost equal.

}, $handleError, function ($exitCode, string $output) use (&$internalErrors, &$internalErrorsCount, $processIdentifier): void {
}, $handleError, function ($exitCode, string $output) use (&$someChildEnded, &$peakMemoryUsages, &$internalErrors, &$internalErrorsCount, $processIdentifier): void {
if ($someChildEnded === false) {
$peakMemoryUsages['main'] = memory_get_usage(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the point of time where phpstan consumes most memory (I believe in >99% cases), so I add main thread memory at that specific time.

@ondrejmirtes ondrejmirtes merged commit 2556918 into phpstan:1.9.x Jan 3, 2023
@ondrejmirtes
Copy link
Member

Thank you!

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

Successfully merging this pull request may close these issues.

Invalid memory consumption shown when using parallel processing and verbose mode
2 participants