PHP-Parser icon indicating copy to clipboard operation
PHP-Parser copied to clipboard

Optimize memory consumption

Open staabm opened this issue 5 years ago • 4 comments

just profiled a codebase via phpstan and blackfire tells me that the classes using most memory are from PHP-Parser.

I am pretty sure you already optimized the hell out of this classes/package, so I just leave this here in case you missed an oportunity. feel free to close if things are already optimal.

a blackfire profile can be found in https://blackfire.io/profiles/6422c219-e7d5-43b1-8f85-ab4fb9b8faa5/graph (I guess the link will not work forever)

I guess the most relevant part (memory wise) is:

image

php vendor/bin/phpstan --version
PHPStan - PHP Static Analysis Tool 0.12.7

php --version
PHP 7.2.27-6+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb  5 2020 16:52:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.27-6+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.30.0~linux-x64-non_zts72, https://blackfire.io, by Blackfire

staabm avatar Feb 12 '20 13:02 staabm

token_get_all() is a PHP tokenizer extension function as far as I can tell, so that is hard to optimize without some magical stuff I'd say.

rask avatar Feb 12 '20 14:02 rask

right, token_get_all() is something which would need to be im proved on the php-src level (if possible).

still 2nd and 3rd most memory is consumed by methods/classes of this lib

staabm avatar Feb 12 '20 14:02 staabm

You motivated me to resurrect this: https://github.com/php/php-src/pull/5176 Gonna write an RFC...

nikic avatar Feb 12 '20 16:02 nikic

Cool, everything perfect then :-)

staabm avatar Feb 12 '20 16:02 staabm

PHP-Parser 5.0 will be using the new object-based token representation, so I'm going to close this one.

nikic avatar May 21 '23 16:05 nikic