Edit report at http://bugs.php.net/bug.php?id=52832&edit=1

 ID:                 52832
 Updated by:         cataphr...@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

Reply via email to