Req #52832 [Opn]: unserialize() performance

From: Date: Tue, 14 Sep 2010 00:58:38 +0000
Subject: Req #52832 [Opn]: unserialize() performance
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154316@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52832&edit=1 ID: 52832 Updated by: cataphract@php.net Reported by: galaxy dot mipt at gmail dot com Summary: unserialize() performance Status: Open Type: Feature/Change Request Package: Performance problem Operating System: Linux PHP Version: 5.3.3 Block user comment: N New Comment: > In my tests doing so reduced the unserialize time from 7 secs to ~0.3 sec on 1000000-size array and size dependency apparently changed to something more like O(n*log(n)) Could you submit a patch with that modification and a test script that exemplifies the speedup? Previous Comments: ------------------------------------------------------------------------ [2010-09-14 02:46:32] galaxy dot mipt at gmail dot com Description: ------------ Performance of built-in unserializer degrades at unexpectedly high rate with the increase of unserialized data size (rather, with number of serialized items). Say, unserializing a plain array of ~1000000 integers might take somewhat 10 secs on average P4 machine, and the worst part is that the time raises quadratically (O(n^2)) with the array size, i.e. ~2000000-ish array would take 40 secs or so. The main performance killer is var_hash linked list where every extracted variable is pushed. It is looked up sequentally from the very beginning up to, in fact, the very end during every push operation (var_push() in ext/standard/var_unserializer.c). It appears that looking from the end (or just storing last used element elsewhere) would save a lot of cycles. In my tests doing so reduced the unserialize time from 7 secs to ~0.3 sec on 1000000-size array and size dependency apparently changed to something more like O(n*log(n)) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52832&edit=1

« previous php.bugs (#154316) next »