|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76599 php_strip_whitespace() is too slow
Submitted: 2018-07-09 15:05 UTC Modified: 2018-08-14 10:46 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: maggus dot staab+php at googlemail dot com Assigned:
Status: Open Package: Performance problem
PHP Version: 7.2.7 OS: win
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
33 - 4 = ?
Subscribe to this entry?

 [2018-07-09 15:05 UTC] maggus dot staab+php at googlemail dot com
in our composer workflows we see php_strip_whitespace() on the hotpath while running "composer update". 
in case time allows, it would be cool if someone could check the C implementation for possible low hanging fruits?

nikic suggested that the function could be faster by not using a outputbuffer:
"Currently it uses output buffering. Replacing that with a direct write to string would be the most obvious improvement"

Expected result:
issue "blackfire run composer install" in your projects directory to get something like


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-17 08:38 UTC]
I tried to remove the buffering, and did a [benchmark](

it has almost 30%+ improve on my CentOS. from about 0.650 to 0.400.

however, I cannot see any improvement on my Windows. the time remains about 0.600+.

I'm not sure if I should submit this patch, since I haven't cleaned up it yet.
 [2018-08-14 08:23 UTC] maggus dot staab+php at googlemail dot com
thx for working on that problem.

Me as the reporter cannot help you to answer this questin.
Hopefully one of the php-src core developers can find some time to chim in.

thx again for your work!
 [2018-08-14 10:46 UTC]
@jhdxr: Yes, please submit a pull request. We can then try to figure out why the speedup is platform dependent and if it's possible to improve it.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Feb 02 07:05:53 2023 UTC