moodle-logstore_xapi icon indicating copy to clipboard operation
moodle-logstore_xapi copied to clipboard

Sites with large numbers of cohorts cannot load settings page, very poor performance

Open matthewhilton opened this issue 2 years ago • 0 comments

Description

  • When installed on a site with a large number of cohorts, the plugin does not efficiently query them in the plugin settings, leading to very poor performance.
  • Performance issues are across most site administration pages since moodle tries to re-query the settings
  • The site in question has 165,652 cohorts
  • The actual xapi settings page tries to make a checkbox for each cohort. This takes ages to load each checkbox and is more or less unusable, and likely will crash browsers on lower spec machines

Version

  • master at 416b92cfd672e02e1c92b5011ee6395bb95a5111 on 2022101800

Steps to reproduce the bug

  1. Enable profiling via site administration
  2. Create a large number of cohorts
  3. Profile the admin search page https://site.com/admin/search.php?PROFILEME=1
  4. Check profiling run. In this site, the profiling run shows the following trace taking a large chunk of time:
admin_get_root
core\plugininfo\tool::load_settings
tool_log\plugininfo\logstore::load_settings
logstore_xapi_get_cohorts

The logstore_xapi_get_cohorts step takes ~10 seconds of execution time.

Expected behaviour

  • Plugin does not impact site performance unnecessarily

Actual behaviour

  • Admin page takes > 10 minutes to load.
  • It tries to make a checkbox for each cohort. If I let it run, it tries to make 100,000+ checkboxes.

Server information

  • Postgresql
  • Moodle 4.1
  • OS: Linux

I would recommend using recordsets to get the data, and refactoring the settings page to use a search/autocomplete box with multi select option.

matthewhilton avatar Apr 24 '23 01:04 matthewhilton