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

[NFR] kernel/memory.c optimizations #893

Merged
merged 3 commits into from Jul 22, 2013
Merged

[NFR] kernel/memory.c optimizations #893

merged 3 commits into from Jul 22, 2013

Conversation

ghost
Copy link

@ghost ghost commented Jul 21, 2013

  • do not call erealloc() on every call to phalcon_memory_observe()/phalcon_memory_alloc()
  • do not waste the very first memory frame
  • free the root memory frame and its structures only during RSHUTDOWN or MSHUTDOWN; this helps reduce the number of calls to emalloc()/efree()
  • use ecalloc() instead of emalloc() when allocating a memory frame (no need to zero out memory)
  • safe erealloc()
  • number of observed variables per frame is not limited with PHALCON_MAX_MEMORY_STACK anymore

On a large scale, when running manual-unit.php, there are almost 15,000 less calls to efree(), 68,000 less calls to emalloc(), cost of the call to phalcon_memory_observe() is almost 2 times less now (tested with callgrind).

@ghost
Copy link
Author

ghost commented Jul 22, 2013

Rebased against the current HEAD

phalcon pushed a commit that referenced this pull request Jul 22, 2013
[NFR] kernel/memory.c optimizations
@phalcon phalcon merged commit 5331bbf into phalcon:1.2.1 Jul 22, 2013
@phalcon
Copy link
Collaborator

phalcon commented Jul 22, 2013

This is great!!

@ghost ghost deleted the mm branch July 22, 2013 15:18
@phalcon
Copy link
Collaborator

phalcon commented Jul 22, 2013

@niden and @sjinks, can you take a look at this please? https://bugzilla.redhat.com/show_bug.cgi?id=977208#c23

@ghost
Copy link
Author

ghost commented Jul 22, 2013

Regarding the CPU detection: this is how I did that for Ubuntu/Debian: https://github.com/phalcon/php-phalcon/blob/raring/debian/rules

PHALCON_DIR = cphalcon/build/safe
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

ifeq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),i386))
PHALCON_DIR = cphalcon/build/32bits
endif

ifeq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),amd64))
PHALCON_DIR = cphalcon/build/64bits
endif

They can't use -march=native on the build host anyway so they don't need to run gccarch anyway.

@ghost
Copy link
Author

ghost commented Jul 22, 2013

Database, memcached etc tests that depend on external services: in 1.2.1 we have implemented a way to skip the test if the service is not available.

Probably we should release 1.2.1 soon so that they don't hack the unit tests much :-)

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.

None yet

2 participants