-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Reduce memory consumption compiling container #18061
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
Conversation
(cherry picked from commit c8cb253)
… to minimise for opcache in place of stripComments, which has been removed along with tests.
@@ -140,7 +141,8 @@ public function dump(array $options = array()) | |||
; | |||
$this->targetDirRegex = null; | |||
|
|||
return $code; | |||
// Replace '/**' comment openings with '/*' for non-debug container to optimise for opcache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimise
-> optimize
(we mostly use American English in code and docs) Thanks!
I was about to comment that this doesn't work for the general case: the str_replace cas alter strings in parameters e.g. |
Good point. I couldn't find any reference to stripComments but I guess it would be BC break as it's public... I'll have another go! |
Hmm unfortunately about 50% of my container is Proxy classes which are generated through What about a more targeted preg_replace looking for opening and closing comments followed by keywords like |
That will fail when a parameter contains actual One alternative solution would be to use a different tokenizer that doesn't load the tokens in memory but rather uses a stream or something. |
indeed, quite a few examples of people struggling with |
Further to #18048 by @nicolas-grekas, keep the same memory savings at Container compilation time but through a str_replace of the whole container string instead of optional addition of extra opening comment
*
as originally proposed.Remove
stripComments
and associated test.