Memory

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
User avatar
John P
Posts: 157
Joined: Sun Nov 04, 2012 7:39 am
Location: Netherlands
Contact:

Memory

Post by John P »

I was looking at 3.1 today locally and noticed phpbb3.1 was using over 7 Mb memory.

Normal behaviour, looking at 3.0 using 3Mb?

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Memory

Post by EXreaction »

I assume this is with debug mode enabled?

Enabling debug mode changes some settings that significantly increases the work that the backend has to do (increasing the page generation time and memory usage). While I do not know the exact about of memory usage without debug mode enabled, I would think it would be roughly similar to 3.0.

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: Memory

Post by MattF »

I've brought this up a few times - phpBB 3.1 will have a SIGNIFICANT memory increase over 3.0

While memory readings differ depending on which version of PHP you are using as well as if any cache extensions are being used, in my local environment I am reading this on the index page of "vanilla" installs:

Environment PHP 5.3.6 with XCache:
phpBB 3.1 : 3.74 MB
phpBB 3.0.12: 1.02 MB

difference: phpBB 3.1 +2.72 MB

Environment PHP 5.3.6 (no cache):
phpBB 3.1 : 10.29 MB
phpBB 3.0.12: 4.97 MB

difference: phpBB 3.1 +5.32 MB
Has an irascible disposition.

User avatar
John P
Posts: 157
Joined: Sun Nov 04, 2012 7:39 am
Location: Netherlands
Contact:

Re: Memory

Post by John P »

Yes it was with debug enabled.but in 3.0 with debug enabled I see only about 3.5 Mb

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Memory

Post by EXreaction »

You need to test with debug disabled on both systems for a real-world comparison. As I said, debug mode significantly increases the load on the server because it does a lot of things that would otherwise be cached, which greatly increases the rendering time and memory usage.

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: Memory

Post by MattF »

EXreaction wrote:You need to test with debug disabled on both systems for a real-world comparison. As I said, debug mode significantly increases the load on the server because it does a lot of things that would otherwise be cached, which greatly increases the rendering time and memory usage.
DEBUG needs to be enabled to see the memory readings.

So I did some more tests. First of all, the DEBUG memory reading is not entirely accurate as it does not take place at the end of all script execution, there are still template injections, cron tasks and garbage collection being performed after the memory usage was retrieved.

The function used in phpbb 3.0 is not for peak memory (it uses memory_get_usage and not memory_get_peak_usage). phpbb 3.1 uses the peak version, which gives you the most amount of RAM used during script execution. This could account for why some of the DEBUG readings are so big between 3.0 and 3.1...

So I did some more tests, all based on the index page only, including disabling DEBUG mode, and echoing both memory_get_usage and memory_get_peak_usage at the very end of all script execution, just before the final exit in the exit_handler, and got these results:

phpBB 3.0.12 using DEBUG: 4.97 MB
phpBB 3.0.12 w/o DEBUG: 5.21 MB / 6.46 MB (peak)

pbpBB 3.1-dev using DEBUG: 10.29MB
phpBB 3.1-dev w/o DEBUG: 7.76 MB / 8.67 MB (peak)

The take away result is the peak memory tested at the very end of script execution without DEBUG enabled:
phpBB 3.0.12: 6.46 MB
phpBB 3.1-dev: 8.67 MB


Further notes: In phpBB 3.0.12, the lowest reading is with DEBUG enabled. This can be explained because it uses memory_get_usage, that is the memory in use at that moment during script execution. The reading of 5.21 MB is higher because it is reflecting the memory usage at the end of all script execution, and you could argue more "stuff" was going on by the end than at the point where DEBUG measured memory usage. The highest reading of 6.46 MB shows that the most RAM used at any time during the loading of the index page peaked at 6.46 MB. Out of curiosity, the peak memory when DEBUG is on, but tested at the very end of script execution was 6.99 MB, so DEBUG only adds about .53 MB of memory load.

In phpBB 3.1-dev, memory is higher when DEBUG is enabled than when disabled, unlike in 3.0.12 and supports what EXreaction was saying about DEBUG mode adding to the memory reading. This is because it is now (correctly) using the memory_get_peak_usage function. Out of curiosity, the peak memory when DEBUG is on, but tested at the very end of script execution was 11.14 MB, so DEBUG adds about 2.47 MB of memory load in phpBB 3.1-dev.

So in the end, with the more accurate memory usage measurements, it looks like this:
phpBB 3.1-dev uses +2.21 MB with DEBUG disabled (or +4.15 MB with DEBUG enabled) compared with phpBB 3.0.12.

Of course, these numbers are all unique to my environment, but the ultimate bottom line is phpBB 3.1-dev uses a "couple" MB more than 3.0.
Has an irascible disposition.

User avatar
John P
Posts: 157
Joined: Sun Nov 04, 2012 7:39 am
Location: Netherlands
Contact:

Re: Memory

Post by John P »

Thanks VSE for this explanation and test.

It's a lot more which I didn't expected.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Memory

Post by EXreaction »

Nice work on the thorough testing there. It's a bit more than I expected, but I don't think it's too unreasonable.

I'm sure develop could be optimized a good bit more (and that might happen after 3.1-a1 depending on if anyone is really interested in reducing memory usage).

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: Memory

Post by brunoais »

If I go forward with the TextFormatter this value will increase by a significant amount...Prepare a nice increase with phpBB 3.2, in that case.

User avatar
Jacob
Registered User
Posts: 102
Joined: Wed Jan 04, 2012 1:41 pm

Re: Memory

Post by Jacob »

brunoais wrote:If I go forward with the TextFormatter this value will increase by a significant amount...Prepare a nice increase with phpBB 3.2, in that case.
In that case I won't be using phpBB 3.2. I'm not sure that I'll upgrade to 3.1, even.
If the extension system is not going to be/can't be used for memory consuming features, and these will be included in the core instead, the usefulness of the extension system will be really limited. For me, anyway.

Post Reply