Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34885 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74086 invoked by uid 1010); 23 Jan 2008 09:02:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 74071 invoked from network); 23 Jan 2008 09:02:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jan 2008 09:02:36 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from [212.25.124.162] ([212.25.124.162:13332] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/F0-64898-AA207974 for ; Wed, 23 Jan 2008 04:02:36 -0500 Received: (qmail 14889 invoked from network); 23 Jan 2008 09:02:31 -0000 Received: from cvs.zend.com (HELO ?127.0.0.1?) (10.1.1.1) by mail.zend.net with SMTP; 23 Jan 2008 09:02:31 -0000 Message-ID: <479702A4.90607@zend.com> Date: Wed, 23 Jan 2008 12:02:28 +0300 User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Nuno Lopes CC: PHP Internals List References: <4794F6DA.8010400@zend.com> <247E16805B904E159ACE8E1EC4CF1D5F@pc07654> In-Reply-To: <247E16805B904E159ACE8E1EC4CF1D5F@pc07654> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Segmented argument_stack From: dmitry@zend.com (Dmitry Stogov) Hi Nuno, Thank you for your notes. Nuno Lopes wrote: > Hi Dmitry, > > The patch looks fine. Although it wastes a bit more memory than the > current implementation, I think it's ok. I think the patch uses exactly the same amount of memory, except that the current implementation uses CPU stack and the patch uses ZE heap. > It also has some memory > fragmentation, which shouldn't be an issue (we don't have functions with > 100 arguments :P). Functions with 100 (or 10000 :) arguments might work slower, but anyway it's an unusual case. > > As a side note, I think the following code could be optimized: Probably it could, but note that the code not just moves the stack pointer, but also destroys arguments there (zval_ptr_dtor). > + while (zend_vm_stack_top(TSRMLS_C) != stack_frame) { > + zval *stack_zval_p = zend_vm_stack_pop(TSRMLS_C); > + zval_ptr_dtor(&stack_zval_p); > } > > I think you can simply discard the last n ptrs on the stack. A > zend_vm_stack_pop(num_elements) would do the trick (or a > zend_vm_stack_pop_until(stack_frame)). That way the function call > cleanup would be a little faster. May be I misunderstood you. Lets commit unmodified patch and then you'll show me a way to optimize it. Thanks. Dmitry. > Thanks, > Nuno > > > ----- Original Message ----- From: "Dmitry Stogov" > To: "PHP Internals List" > Sent: Monday, January 21, 2008 7:47 PM > Subject: [PHP-DEV] Segmented argument_stack > > >> Hi, >> >> The attached patch (for PHP_5_3) implements the segmented argument_stack >> that has the following advantages: >> >> 1) It fixes #43426 and other crashes which occur because of stack >> reallocation. >> >> 2) The whole stack is never reallocated. So we don't have penalties >> because of the while stack copying (it may be 1MB and more). >> >> 3) CPU stack usage reduced, because execute_data, Ts and CVs now are >> stored in the same argument_stack. As result the probability of CPU >> stack overflow is reduced. >> >> 4) func_num_args(), func_get_agr(), func_get_args(), >> debug_print_backtrace() and exception's backtrace now always able to get >> arguments. They didn't work before in case of incomplete "arguments >> frame". For example: "foo(1, func_num_args());". >> >> 5) bench.php got about 1% speedup >> >> I'm going to commit the patch into HEAD and PHP_5_3 on Thursday. >> Any objections? >> >> Thanks. Dmitry. > >