Re: [PATCH] More array filling optimizations
| From: | Dmitry Stogov | Date: | Mon, 26 May 2008 18:20:40 +0000 |
| Subject: | Re: [PATCH] More array filling optimizations | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37901@lists.php.net to get a copy of this message | ||
I have no objections about this patch if it breaks nothing.
Double check it and commit.
Thanks. Dmitry.
Nuno Lopes wrote:
Hi, This patch looks pretty good. I didn't check all the init sizes, but seem ok. Just go ahead and commit! Note to Dmitry: this patch doesn't have the VM part that you didn't like in the previous patch (didn't perform very well..). This just touches the core and it seems ok. Nuno ----- Original Message ----- From: "Matt Wilmas" <php_lists@realplain.com> To: <internals@lists.php.net>; "Dmitry Stogov" <dmitry@zend.com> Sent: Monday, May 26, 2008 11:22 AM Subject: Re: [PHP-DEV] [PATCH] More array filling optimizationsHi Dmitry, all, I looked into and fixed the -1 size and memory overflow error a couple weeks or so ago, and finally updated the patches now. :-) I made the mistake of assuming the code that checks offset/length (in array_splice, etc.) set length correctly, but it can still be negative, which broke array_init_size... Should be OK now there, and also in array_slice and array_chunk. So if it works correctly now, it sounded like the patch could be used? (This doesn't have the compile/VM part, of course.) I would be able to commit these things myself now, but wouldn't unless I was given the OK first! :-) http://realplain.com/php/array_init_size.diff http://realplain.com/php/array_init_size_5_3.diff Thanks, Matt ----- Original Message ----- From: "Dmitry Stogov" Sent: Wednesday, April 30, 2008Hi again Dmitry, Hmm, if a -1 size was passed, I thought it would just make a hugeMatt Wilmas wrote:(bad, obviously), but the tests would still work. (Or I guess itarraysizeexhaust memory_limit.) Anyway, the code for checking the size (length variable) in array_splice() is copied from php_splice(), so maybemightthere'ssome other error if it's becoming -1...You don't think it makes sense to check return_value_used like next/prev/end/reset do? They would only create a 1 element array, but array_splice() could waste time filling a large array that isn't used.The bug causes memory overflow error, but the size definitely shouldn't be -1, as the same tests work fine before the patch.Ithink the function is used a lot to only remove/replace elements, notusingthe return_value: http://www.google.com/codesearch?q=lang%3Aphp+array_spliceIf there's a -1 size bug, the array_splice changes can be reverted and simply have: if (return_value_used) {Ah. I see. My mistake. Of course it makes sense. Thanks. Dmitry./* Initialize return value */ array_init(return_value); rem_hash = &Z_ARRVAL_P(return_value);} - Matt ----- Original Message ----- From: "Dmitry Stogov" Sent: Wednesday, April 30, 2008a-1 asFor some reason "make test" with the patch reported several broken array_splice() tests. Looking in gdb I saw that init_array() gotlotsize of new array. I don't think checks for return_value_used for array_splice() have aof sense. Thanks. Dmitry.