Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Value Optimization #1075

Merged
merged 1 commit into from Aug 13, 2013
Merged

Return Value Optimization #1075

merged 1 commit into from Aug 13, 2013

Conversation

ghost
Copy link

@ghost ghost commented Aug 13, 2013

Added initial support for return_value_ptr to fcall.c and alternative/fcall.c

This will allow us to avoid copy constructors in many cases.

For example, in this case:

$frontCache = new Phalcon\Cache\Frontend\None(array('lifetime' => 10));
$cache = new Phalcon\Cache\Backend\Memory($frontCache);

currently only

$string = str_repeat('a', 5000000);
$cache->save('test-data', $string);
$s1 = $frontCache->afterRetrieve($string);
$s2 = $frontCache->afterRetrieve($string);
$s3 = $frontCache->afterRetrieve($string);

will not waste additional RAM (due to phalcon_execute_internal trick) but this will:

$string = str_repeat('a', 5000000);
$cache->save('test-data', $string);
$s1 = $cache->get('test-data');
$s2 = $cache->get('test-data');
$s3 = $cache->get('test-data');

$s1, $s2, $s3 will use ~5MB each.

The patch adds support for retval_ptr_ptr to fcall.c (the code has to be rewritten to take advantage of retval_ptr_ptr — this optimization cannot be applied transparently without breaking things) and allows functions to take advantage of retval_ptr_ptr if it is available

phalcon pushed a commit that referenced this pull request Aug 13, 2013
Return Value Optimization
@phalcon phalcon merged commit ec5553a into phalcon:1.3.0 Aug 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants