php.net |  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
Votes:1
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-07-09 15:05 UTC] maggus dot staab+php at googlemail dot com
Description:
------------
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?

https://blackfire.io/profiles/04234c24-b8c4-43b0-b23a-0a836b8c766e/graph

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 https://blackfire.io/profiles/04234c24-b8c4-43b0-b23a-0a836b8c766e/graph


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-17 08:38 UTC] jhdxr@php.net
I tried to remove the buffering, and did a [benchmark](https://gist.github.com/jhdxr/24c5b8017f3a80b22e2a23b7c01b6e70).

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] nikic@php.net
@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-2018 The PHP Group
All rights reserved.
Last updated: Sun Dec 16 08:01:26 2018 UTC