MAX_MODINFO_CACHE_SIZE constant value

MAX_MODINFO_CACHE_SIZE constant value

by Евгений Мамаев -
Number of replies: 5
Picture of Plugin developers

Hi!

I currently make some optimizations to my Moodle site (3.11.x) and found this constant MAX_MODINFO_CACHE_SIZE

in /lib/modinfolib.php file

// Maximum number of modinfo items to keep in memory cache. Do not increase this to a large
// number because:
// a) modinfo can be big (megabyte range) for some courses
// b) performance of cache will deteriorate if there are very many items in it

The default value is 10. What number is meant by "the large number"? Is 20 or 30 the large number?

Do I need to increase this value if most of my users enrolled to 15-25 courses?

Average of ratings: -
In reply to Евгений Мамаев

Re: MAX_MODINFO_CACHE_SIZE constant value

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I would strongly recommend that you stop chaning Moodle core code. You're just making it hard for yourself to upgrade.

The message isn't for end users. If this needed to be a user setting (or even a config setting in config.php) then it would be.
In reply to Howard Miller

Re: MAX_MODINFO_CACHE_SIZE constant value

by Евгений Мамаев -
Picture of Plugin developers
I don't change core code, I changed this value in config.php
In reply to Евгений Мамаев

Re: MAX_MODINFO_CACHE_SIZE constant value

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm confused because, unless I'm missing something, it's specified as a constant in lib/modinfolib.php (the file you mentioned). It's not a $CFG setting in config.php
In reply to Howard Miller

Re: MAX_MODINFO_CACHE_SIZE constant value

by Евгений Мамаев -
Picture of Plugin developers
I just added
define('MAX_MODINFO_CACHE_SIZE', 10);
in config.php and can change it's value.
I also have increased CONTEXT_CACHE_MAX_SIZE from it's default value 2500 up to 7500 and got noticeable improvement in speed on course pages and on some admin pages.
All this is not measured in any way with speed tests or some other tools, just by opening a page and noticing a difference. No other config values or server settings (including database) were changed
In reply to Евгений Мамаев

Re: MAX_MODINFO_CACHE_SIZE constant value

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yeh - I'd forgotten about all that. I assume you have been looking at MDL-52419