What is this plugin?
This is a Moodle admin plugin that provides developers with insights into not only what pages in your site are slow, but why. It uses the the Excimer sampling php profiler to so.
It is complementary to the profiler in core which uses Tideways. The key downside to Tideway is that it has a substantial performance hit and can't be used in production to capture everything and only later decide what to keep or analyse.
Looking at your web server logs tells you what is slow but not why. Using Tideways is a critical tool if you can reproduce an issue, but cannot be used to say why something was slow retrospecively last Friday out of hours and you only found out a few days later.
What this plugin is not
This plugin does not aim to replace the core Tideways based profiler, they are complimentary.
Because Tideways instruments every single call, it can be used for a variety of things that Excimer cannot, such as determining in production if a particular code path was executed or not.
This plugin does also not aim to be a full Application performance management (APM) solution such as New Relic. But if you don't have or cannot afford an APM this plugin should be another great tool to have in your tool box.
1) Do no harm
This plugin is designed to be running constantly in production profiling everything and only storing things which are of interest in various ways. So it is critical that this plugin has an extremely low foot print, in all dimensions: CPU, memory, and with IO to the DB, file system and even caches. In the vast majority of requests when things are running smoothly it will discard the profile and it's overall impact should be close to zero. Even when it is storing and processing profiles, keep the impact as low as possible and defer things until needed if possible or worse case to a cron task.
An extension of this is 'don't escalate', meaning if something fundamentally goes wrong at a low level inf level, then avoid making things worse.
2) Don't make me think
Rather that a low level tool which you have to drive, the intent of this plugin is to give clear actionable suggestions about specific changes to code to improve it. There may be many potential reasons why a particular request is 'interesting' in some way.
This plugin aims to detect a range of opportunities to improve performance such as:
- when a session lock is held too long without session changes
- when a session may be a readonly candidate
- when buffering might be better turned off
- when http headers, or a partial body, should be sent earlier
- and diagnoising slow pages retrospectively
- slow cron tasks
- and this list will evolve over time
3) Auto tune configuration
The idea is that this plugin starts with sensible defaults that should work for a wide range of environments and as it records details around your sites performance it adjusts to show you the most relevant things.
4) It's always current
If you had a bad event 6 months ago and things have been running fine, that information is less relevant that something last night which wasn't as extreme but still worth knowing about. As you make changes improvements to code it should be smart enough to prioritise what matters.
Details on the php extension are here:
sudo apt install php-excimer
pecl install excimer docker-php-ext-enable excimer
From Moodle siteroot:
git clone email@example.com:catalyst/moodle-tool_excimer.git admin/tool/excimer
Then login as admin (it should detect the extension), and click through the upgrade process.
Applying core patches
Moodle 3.5 - 4.0:
Apply the patch:
git am --whitespace=nowarn < admin/tool/excimer/patch/MOODLE_35_STABLE.diff
ExcimerProfiler class does not exist. If you use containers, and install the package via apt/PECL, you may see this error. When this happens, you may need to stop and start up the container again, as it sometimes does not load installed packages fully whilst running, and afterwards it should work.
If you find code issues please log them in GitHub here
Please note our time is limited, so if you need urgent support or want to sponsor a new feature then please contact Catalyst IT Australia:
Thanks in particular to the to the Wikimedia Foundation for building the awesome Excimer profiler:
This plugin was developed by Catalyst IT Australia: