unserialize() bottle-neck

From: Date: Tue, 11 Jan 2005 22:40:59 +0000
Subject: unserialize() bottle-neck
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35449@lists.php.net to get a copy of this message
Hi, Thanks to Benchmark_Profiler, I've figured out XML_Indexing_Reader spends most of its time unserializing the index. Example profiling as output by XML_Indexing_Reader::profile(), XML file: 2.5 Mo, index : 150 ko : +------------------------------------------+-----------------+------------+------------+
| Method                                   | Netto Time (ms) | Time (ms)  | Percentage |
+------------------------------------------+-----------------+------------+------------+
| _loadIndex (acquiring read lock)         |            0.11 |       0.11 |       0.18 |
| _loadIndex (reading data)                |            2.70 |       2.70 |       4.20 |
| _loadIndex (unserializing/uncompressing) |           38.22 |      38.22 |      59.49 |
| _loadIndex                               |            1.02 |      42.05 |      65.44 |
| Constructor                              |            0.45 |      42.50 |      66.15 |
| _sortRegions                             |            0.29 |       0.29 |       0.45 |
| find                                     |            1.14 |       1.43 |       2.23 |
| fetchStrings                             |            0.92 |       0.92 |       1.44 |
| fetchDomNodes                            |            4.41 |       5.33 |       8.30 |
| Global                                   |           14.99 |      64.24 |     100.00 |
+------------------------------------------+-----------------+------------+------------+ Gz compression is turned off, so unserialize() eats 59,49 % of runtime. Have you ever encountered such optimization problems with serialize()/unserialize() ? I quite understand that unserializing a 150ko string (the index) into an array take some time, but how to optimize that ? Should I try to write my own (un)serializer ? What about using a binary format which would save disk space as well ? Any experiences welcome, -- og

« previous php.pear.dev (#35449) next »