Moodle performance profiling and memory footprint

Moodle performance profiling and memory footprint

by Martín Langhoff -
Number of replies: 1
I've just committed a bit of code that, with Debug set to on (or a few defines in your config.php) will give you a line with some performance and footprint stats in the footer (only in default theme 1.5). You can also get it to the error logs so you can track evolution of it, or run stats on it on production servers.

With all the options enabled, it looks like this:

/~martin/moodle_HEAD/ 0.219935 secs RAM: 12.1MB Included 101 files DB queries 48 Log writes 1 ticks: 22 user: 18 sys: 4 cuser: 0 csys: 0 Load average: 0.00%

Which breaks down to
- URL /~martin/moodle_HEAD/
- 'Real' time to generate page: 0.219935 secs
- RAM used: 12.1MB (depends on PHP compile flags)
- Included 101 files (include() or require())
- DB queries 48 (optional -- enable it in config.php)
- Log writes 1 (optional -- enable it in config.php)
- POSIX real time in ticks: 22 (requires PHP's posix ext)
- POSIX user time in ticks: 18
- POSIX system time in ticks: 4
- POSIX current process user time in ticks: 0
- POSIX current process system time in ticks: 0
- System load average: 0.00% (if we could find /proc/loadavg or /usr/bin/uptime in the system)

Some of these stats are going to disappear from the footer (POSIX times for instance) but remain in the error log.

Interesting findings so far:
- Default install is really heavy, in particular due to the language dropdown menu top-right, which consumes ~ 10MB and includes ~50 files.
- Even if modules are disabled, their lib and lang files are included. Apparently inclusion of blocks is a bit smarter.
- Turning off modules, filters and blocks makes a huge difference. This shows how good the modularity is. Testing with apache bench, default-install Moodle gave 7 'homepages' per second vs 50 hps for a 'basic' Moodle with only a few 'core' modules on.
- Homepage and course pages in general are really heavy. 'Internal' module pages are much lighter.
- Logging in as admin forces a lot more queries and includes.

Enjoy!
Average of ratings: -