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

Optimize export of large arrays and object graphs #52

Closed
wants to merge 1 commit into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 24, 2023

get rid of sprintf saves a lot of memory

before this PR

➜  memopt git:(main) ✗ php vendor/bin/phpunit --no-results

PHPUnit 10.3.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.10
Configuration: /Users/staabm/workspace/memopt/phpunit.xml.dist

....FFF.............FFFFFFFFFF                                    30 / 30 (100%)

Time: 00:02.630, Memory: 622.16 MB

after this PR

➜  memopt git:(main) ✗ php vendor/bin/phpunit --no-results

PHPUnit 10.3.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.10
Configuration: /Users/staabm/workspace/memopt/phpunit.xml.dist

....FFF.............FFFFFFFFFF                                    30 / 30 (100%)

Time: 00:02.530, Memory: 522.62 MB

=> ~ 17% memory saving

tested on a https://github.com/gnutix/phpstan-typeinferencetest-memory-exhausted with a few dataproviders removed (as the initial example was too massive to profile)

initial discussion in phpstan/phpstan#9914

@staabm staabm force-pushed the patch-1 branch 2 times, most recently from 100263c to 9134734 Compare September 24, 2023 12:59
@codecov
Copy link

codecov bot commented Sep 24, 2023

Codecov Report

Merging #52 (2939668) into main (a59928a) will not change coverage.
Report is 2 commits behind head on main.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##                main       #52   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity        45        45           
===========================================
  Files              1         1           
  Lines            147       151    +4     
===========================================
+ Hits             147       151    +4     
Files Changed Coverage Δ
src/Exporter.php 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@staabm staabm marked this pull request as ready for review September 24, 2023 13:03
@staabm
Copy link
Contributor Author

staabm commented Sep 24, 2023

I don't know what todo about the psalm issue

@sebastianbergmann sebastianbergmann changed the title Optimize exporting big object/array graphs Optimize export of large arrays and object graphs Sep 24, 2023
@sebastianbergmann
Copy link
Owner

Merged manually, thanks.

@staabm staabm deleted the patch-1 branch September 24, 2023 13:07
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