Bug #81378 [Opn]: mb_detect_encoding() performance regression in PHP 8.1
| From: | nikic@php.net | Date: | Tue, 24 Aug 2021 13:35:32 +0000 |
| Subject: | Bug #81378 [Opn]: mb_detect_encoding() performance regression in PHP 8.1 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236039@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81378&edit=1
ID: 81378
Updated by: nikic@php.net
Reported by: gfpuba+php at gmail dot com
-Summary: Performance problem
+Summary: mb_detect_encoding() performance regression in PHP
8.1
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Win10 Apache/2.4.48
PHP Version: 8.1.0beta3
Block user comment: N
Private report: N
New Comment:
Encoding detection now scores encodings based on character properties, and the property lookups are
very expensive and make up the majority of the execution time now.
We don't actually need them for the case of a single encoding, but I assume that was just a
minimal reduction, because calling mb_detect_encoding() with a single encoding doesn't make
sense (mb_check_encoding() should be used instead).
Previous Comments:
------------------------------------------------------------------------
[2021-08-23 20:10:41] gfpuba+php at gmail dot com
Description:
------------
The following code takes 10 times longer to execute on PHP/8.1.0beta3 compare to PHP 8.0.8
Test script:
---------------
$a = str_repeat('abcdef', 10000);
$b = mb_detect_encoding($a, 'UTF-8', true);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81378&edit=1