[wp-trac] [WordPress Trac] #18007: is_serialized trouble for multibytes encoding
WordPress Trac
wp-trac at lists.automattic.com
Mon Oct 8 19:45:54 UTC 2012
#18007: is_serialized trouble for multibytes encoding
----------------------------------------+------------------------------
Reporter: challet | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Charset | Version: 3.2
Severity: normal | Resolution:
Keywords: has-patch needs-unit-tests |
----------------------------------------+------------------------------
Comment (by SergeyBiryukov):
I can reproduce the original bug.
[attachment:18007.2.patch] is a more complete patch using `substr()`.
[attachment:18007.2.alt.patch] is an another take using `count(
str_split() )` instead of `strlen()`.
Unfortunately, a quick test with 3 000 000 iterations of `is_serialized()`
showed that `substr()` is about 2 times slower than direct access, and
`count( str_split() )` is 3 times slower than `strlen()`:
* 11,617s — unpatched
* 24,617s — [attachment:18007.2.patch]
* 33,553s — [attachment:18007.2.alt.patch]
[attachment:18007.3.patch] is an attempt to only use `substr()` if
`mbstring.func_overload` is enabled, and to keep decent performance
otherwise:
* 12,503s — [attachment:18007.3.patch], `mbstring.func_overload` is off
* 26,384s — [attachment:18007.3.patch], `mbstring.func_overload` is on
We have a similar check in `streams.php`: [[BR]]
http://core.trac.wordpress.org/browser/tags/3.4.2/wp-
includes/pomo/streams.php#L17
Replying to [comment:7 kurtpayne]:
> I'm attaching the unit test I'm working on, but I'm stuck until I get
some feedback. You have to apply it then run it as:
>
> `php -d mbstring.func_overload=4 /usr/bin/phpunit -c mbstring.xml`
Note that `mbstring.func_overload=4` only overloads regular expression
functions. For string functions, you need `mbstring.func_overload=2`.
[attachment:18007.unit-test.patch] is the shortened and revised unit test.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18007#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list