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

Preallocate global memory frames in advance #1987

Merged
merged 3 commits into from Feb 7, 2014
Merged

Preallocate global memory frames in advance #1987

merged 3 commits into from Feb 7, 2014

Conversation

ghost
Copy link

@ghost ghost commented Feb 7, 2014

Currently Phalcon preallocates one global memory frame that persists across requests. This PR changes this behavior by preallocating 10 memory frames (in one chunk). This results in fewer memory allocations during request processing.

Valgrind stats (USE_ZEND_ALLOC=0 valgrind $(phpenv which php) /usr/bin/phpunit -c unit-tests/phpunit.xml)

  • before: total heap usage: 7,551,361 allocs, 7,547,627 frees, 869,478,218 bytes allocated
  • after: total heap usage: 7,453,755 allocs, 7,450,068 frees, 859,840,913 bytes allocated

97.5k less memory allocations (this is not the cheapest operation), 9.1 MiB reused.

phalcon pushed a commit that referenced this pull request Feb 7, 2014
Preallocate global memory frames in advance
@phalcon phalcon merged commit 0b7ade8 into phalcon:1.3.0 Feb 7, 2014
@ghost ghost deleted the memory-opt branch February 8, 2014 06:09
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.

3 participants