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" <[EMAIL PROTECTED]>
To: "PHP Internals List" <internals@lists.php.net>
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.



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to