Re: [RFC] Performance improvements
| From: | Dmitry Stogov | Date: | Tue, 13 Apr 2010 15:34:16 +0000 |
| Subject: | Re: [RFC] Performance improvements | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-47917@lists.php.net to get a copy of this message | ||
Hi Jared,
Jared Williams wrote:
Hi Wondering if there is any plans to for new serialization method?Not in this patch.
One of the things that igbinary does is store strings only once, and now that the engine supports string interning natively, seems that serialization and deserialization could benefit. Though I guess igbinary could be patched to take advantage of string interning?Probably it can. However, I've never looked into it, so I can't be sure. Thanks. Dmitry.
-Jared-----Original Message----- From: Dmitry Stogov [mailto:dmitry@zend.com] Sent: 13 April 2010 14:53 To: internals@lists.php.net Subject: [PHP-DEV] [RFC] Performance improvements Hi, I've published all the patches, their description and performance evaluation at http://wiki.php.net/rfc/performanceimprovements In two words the patches give 0-20% improvement even on real-life applications. I'm going to commit them into trunk in a week in case of no objections. Of course, they are binary incompatible. Some extensions (especially VM depended e.g. APC, xdebug, etc) will have to be modified to support the changes. Thanks. Dmitry. Zeev Suraski wrote:Hi, Over the last few weeks we've been working on several ideaswe had forperformance enhancements. We've managed to make some goodprogress.Our initial tests show roughly 10% speed improvement on real worldapps. On pure OO code we're seeing as much as 25% improvement (!) While this still is a work in progress (and not production qualitythecode yet) we want to get feedback sooner rather than later. The diff (available at http://bit.ly/aDPTmv) applies cleanly totrunk. We'd behappy for people to try it out and send comments. What does it contain? 1) Constant operands have been moved from being embedded withinitopcodes into a separate literal table. In additional to the zvalanycontains pre-calculated hash values for string literals. Asresult PHPuses less memory and doesn't have to recalculate hash values for constants at run-time. 2) Lazy HashTable buckets allocation - we now only allocate the buckets array when we actually insert data into the hashfor the first time.This saves both memory and time as many hash tables do not haveedia.org/wiki/String_interning).data in them. 3) Interned strings (see<http://en.wikipedia.org/wiki/String_interning>http://en.wikipMost strings known at compile-time are allocated in asingle copy withsome additional information (pre-calculated hash value,etc.). We tryto make most incarnations of a given string point to thatsame singleversion, allowing us to save memory, but more importantly - run comparisons by comparing pointers instead of comparing strings andavoid redundant hash value calculations. A couple of notes: a. Not all of the strings are interned - which means that if a pointer comparison fails, we still go through a string comparison;toBut if it succeeds - it's good enough. b. We'd need to add support for this in the bytecodecaches. We'd behappy to work with the various bytecode cache teams to guide howrequest.implement support so that you do not have to intern on eachtheTo get a better feel for what interning actually does, considerduplicatedfollowing examples: // Lookup for $arr will not calculate a hash value, and will only require a pointer comparison in most cases // Lookup for"foo" in $arrwill not calculate a hash value, and will only require a pointer comparison // The string "foo" will not have to beallocated as a keyin the Bucket // "blah" when assigned doesn't have to be$arr["foo"] = "blah"; $a = "b"; if ($a == "b") { // pointer comparison only ... } Comments welcome! Zeev Patch available at: http://bit.ly/aDPTmv-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php