Skip to content

Optimize memory consumption - #2680

Merged
ondrejmirtes merged 5 commits into
phpstan:1.10.xfrom
staabm:exp-mem
Oct 14, 2023
Merged

Optimize memory consumption#2680
ondrejmirtes merged 5 commits into
phpstan:1.10.xfrom
staabm:exp-mem

Conversation

@staabm

@staabm staabm commented Oct 14, 2023

Copy link
Copy Markdown
Contributor

tested with

blackfire run --ignore-exit-status php vendor/bin/phpunit tests/PHPStan/Analyser/NodeScopeResolverTest.php

before this PR: (1.10.x@7c4ef6b2a)

I/O Wait      171ms
CPU Time   2min 13s
Memory        368MB
Wall Time  2min 13s
Network         n/a     n/a     n/a
SQL             n/a     n/a

after this PR:

Wall Time  2min 16s
I/O Wait      183ms
CPU Time   2min 16s
Memory        345MB
Network         n/a     n/a     n/a
SQL             n/a     n/a
grafik

$fileHashes = [];
foreach ($files as $file) {
try {
$contents = FileReader::read($file);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think there are more places that do the same thing, please check ResultCacheManager. Or all the places that use FileReader. Thanks.

}

$contents = FileReader::read($path);
$contents = str_replace("\r\n", "\n", $contents);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

here was some normalization going on. removing it did not break tests.

I assume the result cache is not meant to be shared across different computers, therefore it seems not necessary

@ondrejmirtes
ondrejmirtes merged commit bd3f7f3 into phpstan:1.10.x Oct 14, 2023
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you.

@staabm
staabm deleted the exp-mem branch October 14, 2023 19:21
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.

2 participants