Bug #70363 [Opn]: improve performance of case-insensitive mb_*() operations

From: Date: Fri, 28 Aug 2015 02:05:22 +0000
Subject: Bug #70363 [Opn]: improve performance of case-insensitive mb_*() operations
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195577@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70363&edit=1 ID: 70363 Updated by: cmb@php.net Reported by: jhdxr@php.net -Summary: why mb_* so slow? +Summary: improve performance of case-insensitive mb_*() operations Status: Open Type: Bug Package: mbstring related Operating System: irrelevent PHP Version: 7.0.0RC1 Block user comment: N Private report: N New Comment: Apparently, this is not a general mb_*() issue, but rather related to case-insensitive operations, as Yasuo has pointed out. It seems that this is been caused due to the lack of native mbfl_*() case insensitive operations, so PHP converts $needle and $haystack to upper-case intermittently, what has some overhead. Anyhow, this is not a bug, but rather a feature request to improve the performance of case-insensitive mb_*() operations. Previous Comments: ------------------------------------------------------------------------ [2015-08-27 11:57:31] yohgaki@php.net Interesting result. It seems https://3v4l.org/d8IAo is a worst case and mbstring's case insensitive code has performance issue in general. Tried case sensitive https://3v4l.org/ZF3TK version. The result varies, but it seems mb_* functions have improvement margin. I get slower results consistently with current master on my real PC. (I suppose 3v4l is VM or container) If I use $raw = '0123456789abcdefghijklmnopqrstuvwxyzあいうえおかきくけこさしすせそなにぬねのはひふへほまみむめもやいゆえよわをん'; for https://3v4l.org/ZF3TK, case sensitive version mb_strstr() is a little faster. BTW, pcre became a lot faster than 5.6. This is the reason why mb_strstr() is a little faster than pcre version. If anyone could make more generic benchmark script, i.e. benchmark mb_*() functions, it would be helpful. ------------------------------------------------------------------------ [2015-08-26 16:07:52] jhdxr@php.net Description: ------------ It seems mb_* is much slower than the original string related method, there are lots of data in the user contribution section of the manual (<http://php.net/mb_strlen>, <http://php.net/manual/en/function.mb-strtolower.php>). and today I read a post talk about this topic (<https://v2ex.com/t/216212>), and the author use an regular expression instead of mb_*, which is, and to my surprise, much faster. Here is his code: <https://3v4l.org/d8IAo>. So i'm wondering why mb_* is so slow. Are the users use them in a wrong manner, or our implements has some problem? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70363&edit=1

« previous php.bugs (#195577) next »