Bug #77536 [Com]: finfo considerably slower on 7.3 vs. 7.2
| From: | danack@php.net | Date: | Tue, 29 Jan 2019 02:33:37 +0000 |
| Subject: | Bug #77536 [Com]: finfo considerably slower on 7.3 vs. 7.2 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-219263@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77536&edit=1
ID: 77536
Comment by: danack@php.net
Reported by: jscaltreto at gmail dot com
Summary: finfo considerably slower on 7.3 vs. 7.2
Status: Open
Type: Bug
Package: Filesystem function related
PHP Version: 7.3.1
Block user comment: N
Private report: N
New Comment:
Please could you run the scripts through strace to identify the system call that is causing the
difference: https://linux.die.net/man/1/strace
Possibly also, although it might be clear to you what the official dockers images are, please could
you link to them or name them as they are on docker hub. Or even better provide a Docker compose to
run the two things through.
Previous Comments:
------------------------------------------------------------------------
[2019-01-28 23:57:04] jscaltreto at gmail dot com
Description:
------------
Calls via finfo to lookup mimetype of files take 30%+ longer to run on php 7.3+ than on 7.2. In an
extreme case on a cpu-loaded machine I've observed finfo->file() calls taking upwards of
500ms in 7.3, where on the same hardware with the same load the calls typically take <1ms for the
same file in 7.2.
The included test script can be executed in both 7.2 and 7.3 to illustrate the problem. I've
also created a simple test using official docker images to reproduce the issue: https://gist.github.com/jscaltreto/8f6adf38e7abb08a831ef37b84c14ace
Test script:
---------------
<?php
$iters = 1000;
$start = microtime(true);
for ($i = 1; $i <= $iters; $i++){
$finfo = new finfo(FILEINFO_MIME);
$type = $finfo->file("/bin/sh");
unset($finfo);
}
$ttl = microtime(true) - $start;
echo "Took: $ttl\n";
?>
Expected result:
----------------
7.2 and 7.3 should execute the script in roughly the same amount of time.
Actual result:
--------------
7.3 takes 30%+ more time to execute.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77536&edit=1