tekrat

PHP FatMM

The PHP Fat Memory Manager Patch trades efficient memory use for CPU time. This is done by allocating a large block of memory and persisting it across multiple requests. This is different from normal processing where memory is completely allocated and free’d for every request and is done so in small chunks.

The amount of memory allocated is configured by PHP configure option –with-fatmm=SIZE where SIZE is the size in Megabytes to allocate. In the event that the memory required by a request exceeds SIZE, the normal PHP memory allocation will be used and free’d at the end of the request.

Please let me know what success or failures you have with this patch so I can make improvements!

This is a experimental patch for speed freaks, please don’t expect it to work well or to be added to core PHP.

BC Note: The patch contains non-binary compatible changes (in-lining of emalloc/free calls), so this means you’ll need to recompile any other .so extensions you built against the newly patched PHP build. Typical errors would be something like: “php: symbol lookup error: xyz.so: undefined symbol: _efree”

Download:

PHP-5.2.6: php-5.2.6 patch

PHP-5.2.6-Suhosin: php-5.2.6-suhosin patch

(does not provide Suhosin protection on FatMM allocs)

Rough speed comparison in requests per second using Apache Bench, test script filled an array with integers, results will vary: