Catalyst performance patches for 19/HEAD

Catalyst performance patches for 19/HEAD

از Martín Langhoff در
Number of replies: 71

I have just pushed to git.catalyst.net.nz/git/moodle-r2.git a new branch called mdl19-perf . It has a large patchseries (some 130 commits) that I have been working on over the last month to address the performance problems in 1.8/1.9. The work is based on different things we have been trying over the last 4 months. It hasn't been fun or easy, but here it is at last.

You can get it with a recent git (1.5.2 or 1.5.3) doing

git clone http://git.catalyst.net.nz/git/moodle-r2.git
cd moodle-r2.git
git branch --track mdl19-perf origin/mdl19-perf
git checkout mdl19-perf

To review the code easily you can do

gitk b6c2b618ebb76717b43b94e9f27d94812deeb322..

Status

The code as it stands does not install or upgrade cleanly. To try it, you have to

  • Run the Moodle "install" process from CVSHEAD (hint: do git checkout origin/cvshead)
  • Switch to the mdl19-perf code (hint: do git checkout mdl19-perf)
  • build the context paths with php -r 'include("./config.php");build_context_path();'

Outside of the install/upgrade process, the 1.8 version of the code has been tested quite a bit @ Catalyst, but this is a largely untested 1.9 port of it -- I have had to change a few things. So it's probably rough here and there.

MySQL support hasn't been tested yet either - but I have removed all the Postgresisms from the code. So it should work چشمک

Testing

You will want to have a moodle install with a few thousand user accts, and few thousand courses with content and lots of enrolments. Tons of them چشمک

To evaluate the changes, testers should at least

  • Enable perf logging, make sure you get DB queries entries and that you read it in apache's errorlog (not on the page footer). The page footer does not appear in the heaviest page of moodle today - login/index.php .
  • Disable rcache

For developers it is very interesting to additionally

  • Enable full query logging at the DB server (and tail those logs)
  • If possible have the DB server on a separate machine

(It is really important to disable rcache for developers -- we have been relying too much on it, and that has actually made things worse.)

Interesting things to test:

  • Login as
  • Role switching
  • Participants list
  • My courses blocks
  • Overrides
  • Privilege removals while you are logged in (This actually is quite nice - login with 2 webbrowsers, one as admin, the otherone as a lowly user, and add/remove privileges from the lowly user, who should see them come into effect immediately. New enrolments don't always appear immediately, but enrolment removal, and capabilities changes are always instant.)

And of course you'll want to test performance of key operations چشمک An easy way to do it if you have the git checkout is to switch branches.

  • git checkout origin/cvshead (to get CVS HEAD)
  • git checkout mdl19-perf (to go back to the perf branch)

Note that on every "switch" you have to delete your cookie and re-login everytime (if you don't delete your cookie it will complain quite a bit.)

Before it gets into HEAD

There are a couple of things I need to sort out before this gets into HEAD proper.

  • The most important one is that it breaks installation and upgrades. The easy fix is to throw whatever's needed into has_capability() but that will probably have a negative impact on runtime -- and we cannot afford that. So I will be working on a fix that doesn't trigger additional DB queries or anything expensive in runtime.
  • I hope works on MySQL لبخند If anyone can confirm -- great. Otherwise I'll test it when I get there.

Once those key things are done, it'll probably be all clear and I'll land it into HEAD. There are also a couple of things that appeared in the porting from 18 to 19/head need to be sorted -- from my notes:

  • update_course_icon() we need to walk the callers to ensure the check for capabilities properly
  • Also - audit $USER->editcourseallowed -- unsure of which approach is the correct one
  • kill sql_intarray_to_in() -- implode() will do
  • get_role_users() needs significant rework -- my merge drops some functionality
  • course/lib: review capchecks for viewfullnames
  • get_my_courses() and callers need a review around capchecks

Hacking on this code

If you want to work on the code before it lands in HEAD (which will take a couple of days), just work in git and then use git-am to export the patches and post them here in GDF for discussion. Or push them to repo.or.cz if that's easier.

The new code is a bit of a balancing act, so we need to be careful around it to make sure changes improve it rather than regress it. I have made a practice of measuring the DB queries, overall time and memory (if applicable) of the pages that each code change affects. This made me realise that some changes that I thought "of course" would make things better... didn't. Or made things 10% better in one place, and 300% worse in other places.

Measuring is the only way we can evolve core Moodle code to be scalable. So if you are proposing a patch, it'll be great to see it come with some numbers. A bit for boasting if you want, but mainly to show what cases you have tried and how it fares.

Once the code is in CVS I'd like to keep hacking on it (mainly accesslib and other performance-critical parts of core) with a "propose patch, get peer review in GDF, commit to CVS" approach. At least for a while.

Constant number of DB queries

For me, the most important thing to learn from this patchseries is that the core of Moodle must get its job done in a constant number of database queries.

What does this mean? The most expensive operation we have is a database query. Every time PHP "talks" with the DB, it could do thousands of function calls and internal operations. Thousands. So every time we talk with the DB, it has to be meaningful... which may mean the PHP side does a bit more preparation before the query, and post-processing of the data returned.

All the DBs supported now by Moodle can do complex JOINs and subselects -- so we can make those opportunities meaningful. The main issue we have today in moodle is that we often code like

 $course = get_records('courses');
 foreach ($courses as $course) {
      $forums = get_records('forum', 'courseid', $course->id);
      foreach ($forums as $forum) {
          $discussions = get_records('discussions', 'forum', $forum->id);
          foreach ($discussions as $discussion) {
              // here we call a function
              // that does some DB queries for _each_
              // discussion
              forum_do_somthing($discussion);
          }
      }
}

The code above will cause a huge storm of DB queries that grows exponentialy with the number of courses/forums/discussions/posts. Most of the time we don't even realise as we are coding it!

(If you have only one test course, with one forum with 3 dscussions on it, and the DB is on the same machine as apache, you don't see a thing. That is why it is important to have those query logs enabled on full, and some real data in your DB.)

And in 99% of the cases (at least for moodle) we can do it in a fixed number of DB queries. Yes, the query will be a bit slower than the little individual queries. But it will be one instead of thousands -- which scales a lot better.

It takes a bit more thinking and work, but code that looks like

 $sql = "SELECT c.coursefields,...
                f.forumfields...
                fd. forum discussion fields
                fdp. forum post fields
         FROM ... 
         JOIN ... ON ()
         ...
         WHERE ..."
$rs = get_recordset_sql($sql);
if ($rs->RecordCount()) {
     while ($rec = fetch_next_record($rs)) {
          // forum_do_something() will never do any DB work
          // because the controlling look as grabbed all the 
          // required data into a single record
          forum_do_something($rec);
     }
}

means we can scale pretty much linearly -- rather than the log(log(log(O^n))) in the previous example. The key strategy above is to move the SQL work out of the inner functions and to the controlling loop. It does mean rewriting some of the inner functions, and in some cases they'll have to be specialised to the specific work required in that loop.

Of course, there are always exceptions where you will have to do some DB work deep inside the loop. But hey, they will be just that: exceptions چشمک

There are some very core areas of moodle that I haven't gotten to yet and show the problem. With a bit of effort and testing, we can optimise them to work in a constant number of DB queries...

  • The course "main body" display loop in course/view.php and the course formats. It's doing a ton of unneeded DB work that could be done in 1 DB query. Just restore the "test" course and look at the DB traffic for each coursepage view.
  • mod/forum mailout code
  • My Moodle

I'll be very happy if anyone wants to tackle any of those 3 above. (I'll probably have a go at My Moodle at some point).

If we start hacking with this concept in mind -- get the job done with a constant number of queries regardless of the number of courses/users/enrolment/stars-in-the-sky -- we can get moodle to deliver all the important pages with perhaps < 30 DB queries.

And if we can get there -- or close to that -- Moodle will be the fastest most scalable LMS around. The core API -- specially modules API -- is very well suited for this coding approach. With a few tweaks here and there... چشمک

Finding your way around the new code

Make sure you read the commit messages, and the top of accesslib. Should answer 99% of your questions چشمک if it doesn't or is unclear, ask away.

While I work on finishing this for the merge, I'll monitor GDF to answer questions and coordinate.

میانگین امتیازات:  -
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Silly stats. It's 133 commits

$ git log b6c2b618ebb76717b43b94e9f27d94812deeb322.. | grep -c '^commit'
133


$ git diff --stat b6c2b618ebb76717b43b94e9f27d94812deeb322.. 
 admin/cron.php                         |   15 +
 admin/modules.php                      |   55 +-
 admin/roles/allowassign.php            |    2 +
 admin/roles/allowoverride.php          |    2 +
 admin/roles/assign.php                 |    6 +-
 admin/roles/manage.php                 |   23     +
 admin/roles/override.php               |    4 +
 backup/restore_form.html               |    2     +-
 blocks/admin_tree/block_admin_tree.php |    9 +-
 course/category.php                    |    7 +-
 course/edit.php                        |    4 +
 course/index.php                       |   70 +-
 course/info.php                        |    3 +-
 course/lib.php                         |  109 +-
 course/search.php                      |   13 +-
 course/unenrol.php                     |   13 +-
 course/view.php                        |   17 +-
 enrol/manual/enrol.php                 |    7 +-
 enrol/mnet/enrol.php                   |    5 +-
 enrol/paypal/ipn.php                   |    2 +
 group/assign.php                       |   23 +
 lib/accesslib.php                      | 3456 ++++++++++++++++++--------------
 lib/datalib.php                        |  919 +++++++--
 lib/db/upgrade.php                     |    2 +-
 lib/deprecatedlib.php                  |   22 +-
 lib/moodlelib.php                      |  109 +-
 lib/pagelib.php                        |   46 +-
 lib/setup.php                          |    9 +-
 lib/weblib.php                         |  105 +-
 mod/chat/lib.php                       |   28 +-
 user/index.php                         |    4 +-
 user/view.php                          |   11 +-
 32 files changed, 3184 insertions(+), 1918 deletions(-)
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
Great to finally see this, Martín, THANKS, well done!

As you know I really want to see this in 1.9 even if it delays the release for a while, so I'll be asking everyone here to test it and kick the tires (and the windows and the engine).

About the upgrading issue ... How about if admin/index.php checks the current version of Moodle, and if older than a certain date, sets something in the $SESSION global like $SESSION->upgradingaccesslib. Then all you need is a little check in has_capability() like:

if (!empty($SESSION->upgradingaccesslib)) {
 return true;
}
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
> well done!

Cheers! Not counting my chicks before they're hatched though -- still a bit to go... چشمک

WRT SESSION->upgradingaccesslib -- yes, that's roughly the approach I want to take. It has to be done pretty carefully to cover all the cases (install, upgrade from 1.7/1.8/etc) and not add DB work to the hot paths of accesslib.

/me off to work on it...

(Edit: any feedback from your wrt installations on mysql? questions?)
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Ok, making some progress here - clean install is sorted, will push that out soon - but I am not sure I can cover all the upgrade "trigger" mechanisms.

I think I have to deal with

  • adminuser logs in, goes to /admin, deploys new code, refreshes page (this is working ok)
  • adminuser logs in, looking at homepage, deploys new code, refresh
  • adminuser logs in, looking at random page, deploys new code, refresh
  • new code is deployed, adminuser visits homepage with a prior session, logs in
  • new code is deployed, adminuser visits homepage without a prior session, logs in

Hmmmm. It's a lot of surface to cover. Any hints?

Edit: also, adminuser hits /admin without prior session. This is working already.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
Using the SESSION global should work most of the time ... upgrades of core stuff already happen BEFORE any log in is necessary. The main things to cover are

someone (anyone) looking at /admin (already working)
admin user already logged in and on home page.

for the second there is a bit of code in /index.php you can update the version number of:
// check if major upgrade needed - also present in login/index.php if ((int)$CFG->version < 2006101100) { //1.7 or older @require_logout(); redirect("$CFG->wwwroot/$CFG->admin/"); }
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Perfect. Anyone else will get a barrage of errors.

(hack hack hack hack hack)

It's taken a bit of work but I've just pushed a new version out. For those tracking it using git, just

git pull 

Or you can say

git fetch
git checkout mdl19-perf
git merge origin/mdl19-perf

The patchseries is also visible here...
http://git.catalyst.net.nz/gitweb?p=moodle-r2.git;a=log;h=mdl19-perf

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Wen Hao Chuang در
Thanks for sharing Martin! This is really great contribution to the moodle community and we really appreciate that!

We (SFSU) will be happy to help testing on MySQL. Few quick questions here:

1. Do you have a working performance branch (e.g. mdl18-perf) for Moodle 1.8 that you could put up on git.catalyst.net.nz/git/moodle-r2.git ?

2. Other than what you mentioned, is there any other "known issues/bugs" that you found on 1.8/1.9 with these performance patches (as you mentioned that the 1.8 version of the code has been tested quite a bit @ Catalyst)?

3. Have you guys came up with any specific test plan or developed any testing strategy for these performance patches? It would be great if we could do a nice division of labor/collaboration among the Moodle community to help out testing these patches. لبخند

Thanks again for your great work and efforts, we really appreciate that! لبخند
In reply to Wen Hao Chuang

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Do you have a working performance branch (e.g. mdl18-perf) for Moodle 1.8

The branch exists, but it's not public at the moment. If we start seeing high quality patches on top of my mdl19-perf branch that improve performance significantly, I'll have a good incentive to release it چشمک

any other "known issues/bugs"

I've listed them above چشمک the Catalyst test team gave me a clean bill of health.

Have you guys came up with any specific test plan or developed any testing strategy for these performance patches?

Our test team used the testing scripts described in docs.moodle.org, plus my notes -- which I've reproduced above. They were usign 2 webbrowsers side by side, with different logins. And I force-fed them a 40 minute spiel on how roles work and tricky corner cases of the roles functionality, including the magic "ghost guest enrolment" users get. And I set them up with dual moodles, a "reference moodle" and a "performance-patches moodle", so they'd do a comparison.

Anyway, see under the "Testing" title -- if you have more specific questions, you'll have to be... more specific.

And yeah, if SFSU wants to help with testing and patches, help is more than welcome. Specially high quality patches -- there's a little to-do list in my opening post above.

People wanting to help do need to make sure they have a good understanding of roles -- it's taken me a few reads of the documentation in the wiki to "get" all the implications). And if you are going to get into the code, a very good read of the commit messages and the new code.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Dan Poltawski در
Martín,

Thanks for your work on this لبخند

I'm just reviewing the changes now.

Regarding admin_tree block optimisation (commit
694536cae40457e4471dca6d7fb71fab38564a86 - I think thats how I refer to it with git??), its removing functionality.

Previously users with different permissions could have granular access to the admin menu for the items they have access to, so limiting to only users with moodle/site:config would break that. Although I agree that that menu is slowww to render and needs fixing. Perhaps permissions for the various elements could be gathered and checked first (...without me looking at the problem in detail).

Dan
In reply to Dan Poltawski

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
I suspected it would ناراحت but the current /admin menu system is frankly misdesigned.

Can you give me a good example of how to setup test case? I'll try and debug it with it.

(Add that to the list of things To Do: rework the admin settings thing so that we don't need to load _every file under the sun_ just to show a dinky list of html links. Whoever fixes that gets a free beer from me چشمک )
In reply to Dan Poltawski

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
Dan - can you test the latest mdl19-perf? I pushed out this commit that should address the prob: http://git.catalyst.net.nz/gitweb?p=moodle-r2.git;a=commitdiff;h=8a97febef50f03e5702486e16b9748dde72086b1
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Dan Poltawski در
Yep, looks like it does. Although yuk yuk yuk ;)

I'm going to try and get some time to take a look at the admin settings to see if we can get those capabilities in a better way.

Edit: Oh, no there isn't without a rewrite لبخند
In reply to Dan Poltawski

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
Main problem with shortcuts like this is the loss of flexibility. People who have created plugins with various capabilities (eg admin reports) should not have to edit a has_admin_caps() function.

Why not do it dynamically and then cache the single boolean result in the session?
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

the loss of flexibility

I agree. "Less than ideal" as per the commitmsg. But see below...

Why not do it dynamically and then cache the single boolean result in the session?

It still costs a ton, and the cost is borne by any pageview to the homepage. So we'd do it for every new session -- transient visitors to the homepage, guests, google and bots which forget their sessions, every change of session (login, loginas), etc.

Just to decide whether to show the admin menu or not costs a good 25 files and 15 DBqs (it reads all of "/admin"!). On large sites some of the DB queries are heavy - with my "large" DB the cost is ~1s.

(That is why I say that to understand my patches yu have to be running Moodle tailing the DB's full SQL logs. Have you tried it?)

With this patch, we have 0 DB cost, we call has_capability() a couple of times, which is a double-nested for() in-memory. So it makes Moodle behave more elegantly with the DB چشمک

As far as I can see, the only other way to do this cheaply I can see it to rework the /admin infrastructure to be efficient. The current flexibility if achieved at a huge cost -- read/parse/execute everything under /admin. But I haven't even looked at that -- sounds like a sizable job.

In the meantime, it's a tradeoff. A hardnosed one, and I'm happy to take patches on it or achievable suggestions on how to do the job better with a similar cost to what I've done.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
Possibly we can have a compromise with one new capability to show/hide the whole block, and then IFF that passes then do the dynamic parse I suggested.

It just means that role editors need to remember to turn on that one capability but at least it's configurable in the GUI then.
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

one new capability to show/hide the whole block

Yeah, doesn't sound too bad. And a big bug filed that says "rework /admin" چشمک

In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

People who have created plugins with various capabilities (eg admin reports)

None of the plugin APIs I work with can add stuff to /admin (modules, filters, blocks, auth, enrol)... which would mean that /admin is "core" and not something we need to take a performance hit over to support pluggability down to each page view.

A quick look around admin/reports didn't show any code that seemed to add itself to the admin menu, at least not inside the reports directories. Can't find any related doco in docs.moodle.org .

The best fix I can think of is walking whatever is pluggable at install time (or /admin/index.php time). At that point, we can add suitable entries in config_plugins, and use that to suss out cheaply what we need to display. In my reading of the new /admin infrastructure, I couldn't see an easy way to do it -- but you guys know it a ton better...

In the meantime, the only way I know for devs to add entries to the admin_tree menu is to edit files under /admin, and that's not a public API, and generally not supported (actually a good thing if we do end up needing to rework it significantly). So I suspect it is core dev area...

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Mark Nielsen در
Hi Martin,

The /admin area is a nice area to store admin only tools since none of the other plugins are really designed to offer such functionality. Also, you can add items to the admin_tree menu by adding files to the /admin/settings directory. This then allows you to then add menu items for your admin tools.

Just wanted to chime in to let you know that this code is being used in third party development.

Cheers,
Mark
In reply to Mark Nielsen

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Mark - thanks. Do you ever use custom capabilities to decide whether to display parts of the tree to some users?

If you do, or think that perhaps one day you might need to do -- is it too terrible a thing to add that capability to the admin_tree block? چشمک

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Eloy asked me in private for a writeup on architectural description of the patchseries. So I've taken one of my initial descriptions to MartinD of the patchseries, and expanded it here...

Principles

There has been a lot of brain-squeezing to make sure that the new accesslib does its job with (in order of importance):

  • the number of DB queries stays fixed regardless of data size
  • the least number of DB queries
  • the queries are smart / fast
  • sometimes we cannot take all the decisions in SQL - moving the minimum number of rows, JOINed with whatever extra data we need to make further decisions in PHP

It's taken me some long hours and lots of trying to figure out how to do some things in 3 queries, transferring the minimal amount of rows required, and not murdering the DB with complexity.

Accessdata

The most important new data structure is what in the code I call "accessdata", usually appears as $ad, and we cache it in $USER->access for the logged in user, and in $ACCESS[$userid] for others. It replaces $USER->capabilities.

Have a look at the top of the new accesslib for a description of the datastructure. In early patches it's called "sess" or "accessinfo", you'll see I later renamed it to accessdata and $ad everywhere.

It pretty compact -- $USER->capabilities could grow to megabites of data on large sites.

Accessdata is populated with get_user_sitewide_access() and the rest of the magic is in a double-nested bottom-up loop, in has_cap_fad(). The "_fad" means from access data, functions ending in _fad() can be used when you've build up the accessdata for a user (cost: 3DBq) -- the other functions do talk with the database.

(BTW, when reading has_cap_fad(), initially skip the first double-nested-loop that deals with context switches. It only makes sense once you've seen the "main" double-nested-loop.)

Accessdata loads in stages

Even with the new compact data structure, accessdata initially grew quite a bit for large sites because it was reading all the relevant data for a user, and overrides to news/teachers forums across 6K courses were huge.

So we now load accessdata in stages. get_user_sitewide_access() loads all the interesting contexts but not below the course contexts. No course or block roledefs or RAs are loaded. The first time there is a call to has_capability() that is below a courselevel, all the interesting accessdata for that course is loaded into $USER->access. by get_user_access_bycontext(). It takes 2 or 3 DBq.

So when users login they get a $USER->access we call get_user_sitewide_access() and then if they hit the homepage, get_user_access_bycontext() for the sitecourse. With those two they can navigate around alright, until they go to a coursepage or visit a module or block page in one of their courses. When that happens, get_user_access_bycontext() is called and populates $USER->access appropriately.

It's Just-In-Time loading of accessrights. They are never unloaded, so if you navigate all your courses, you'll end up with a large session.

This is a bit of a problem for my-moodle for example as it's a single page that needs to query modules across many courses. I'm still thinking about how to address that one...

Contexts exist

There is a major assumption in the new code - that all the interesting objects (users, categories, courses) have their contexts in existence. So we now make damn sure we create course contexts.

There is a bit of work in maintaining the newly minted "path" and "depth" fields, which is important when categories move, and when courses move categories.

In case we forget, cron will populate them. If there is ever a problem with "wrong" paths, we can call build_context_path(true) and that will rebuild them.

Dirty contexts

We now mark contexts "dirty" to force logged in users to reload their $USER->access array, but only if a context they are using is marked dirty. Some ops taint /1 (the systemwide context) and everyone reloads. But course-context changes and below only affect users visiting that course.

Load context "object-records" we know we are going to need

A lot of the unneeded DB traffic we have in 1.8 is around fetching context objects. Here, reliance on rcache and the contextcache has been quite damaging, because

  • we all assumed it was ok to keep fetching them one at a time -- it's not ok when you need more than 10 of them...
  • it made the assumption that rcache was as fast as RAM, and in-memory rcache is limited to the pageview... all shared rcache implementations have a significantly higher cost than "in memory". eaccelerator has a high serialise/unserialise cost, memcached adds tcp latency to that.

I have tackled this with 2 strategies...

First, the course page loads all the interesting contexts for the course into the contextcache in one DB query with get_child_contexts(), and it saves a ton of DB traffic on the course page.

I think this could be improved upon with a get_course_context_and_related() to fetch contexts for all the parenthood, the course plus all the children in 2 DBq, and return the course context to the caller. And perhaps calling it from require_course_login() would show a good upside. Neither change is hard to code, but before we merge it in we'd need to study how it behaves across different modules and block pages. If anyone wants to help here... چشمک

Second, where I could, I reworked functions that return large records arrays that have related context to JOIN against context, and return the objects with a "context" subobject. For example - get_my_courses() - the caller needs to run capchecks against it, so each course in the array now carries a 'context' property that is actually an object.

It sounds a bit ridiculous -- the context object-record is built (faked?) "by hand" from the extra fields grabbed by the JOIN. I don't mind -- it saves hundreds of completely unneeded DB queries. We should do this a whole lot more around Moodle - grab "richer" rows that have all the data you need using JOINs. Those JOINs are so cheap that they are almost free of cost, specially compared with the latency you have on each DB call...

Misplaced capability checks

Lots of cap checks have started appearing in funcions that should not change their behaviour depending on USER or on anything external -- where I could, I moved the capchecks to the controlling page or function. In general, calls to has_capability that check against $USER->access should never appear in accesslib/datalib/weblib.

Bad loops

I have fixed performance problems in the core pages that I was looking at when I could, even if they weren't related to accesslib. Sometimes I couldn't read the SQL logs with so much silly SQL being thrown about so I just had to clear it up a bit, so I could see the accesslib SQL traffic چشمک

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Quick note about costs...

  • DB queries are the most expensive thing. Hugely expensive.
  • serialise/unserialise are very expensive. This first came as a surprise to me, but then I realised that PHP has gotten quite a few security bug reports about buffer overruns during unserialise, so it's now paranoid... and slow.
  • Large sessions force large serialise/unserialise - which can kill large sites
  • rcache is only as-fast-as-memory when it's internal. both eaccelerator and memcached are expensive wrt serialise/unserialise, and memcached adds tcp costs
  • include/require are slow, we are including every file under the sun at the moment
  • empty() is slow (and it covers up for errors)
  • if you know what datatype you are dealing with, use the appropriate op rather than empty() -- it's faster and you'll notice bugs earlier
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Mike Churchward در
عکس Core developers عکس Plugin developers عکس Testers
This is really useful stuff!

include/require are slow, we are including every file under the sun at the moment

What's the solution to that? Presumably, any part of the system only includes what it needs, and the main part includes the general libraries. What could we do different? Is an include/require slow when using the '_once' versions, and the files are already included?

empty() is slow (and it covers up for errors)

Never knew empty() was that expensive. I think its used a lot to check for !isset() as well as zero value. Generally, !isset() should not be needed (likely coded badly), but there are cases where it is needed. Is isset() as expensive as empty()?
In reply to Mike Churchward

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

any part of the system only includes what it needs, and the main part includes the general libraries.

Exactly. A bit of discipline when deciding to include stuff you don't really need.

I think its used a lot to check for !isset() as well as zero value

empty() is used for a lot of stuff. It's a lazy "Do What I Mean" type of operator, it will check isset(), is_null(), count(), '', 0, false, and a dozen more things. As such, it is pretty ambiguous.

It is good to use for if empty($CFG->foobar) but in a tight loop, where it's one thing that a var is set, and a very different one that it has a value of 0, empty() is slow, and ambiguous (that is - often wrong).

Generally, !isset() should not be needed

Au contraire! isset() is fast, and precise. Have a look at has_cap_fad() -- isset() is used to check for the existence of a key unambiguously.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

There - I pushed out 2 commits.

With the first one, if you define the MDL_PERFINC constant you will get a useful listing of files included/required, with their sizes. Gives you an idea of the work that the PHP engine has to perform to parse it.

Reading the output I could see that the typo3 libs are huge. Looked at them for a minute and realised that we are including 144KB of PHP that I think we never use (class.t3lib_div.php). So I've removed the require line. Will need confirmation from Eloy on that one.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Mike Churchward در
عکس Core developers عکس Plugin developers عکس Testers
What I mean by 'isset()' not being needed, is that generally you should have variables initialized. Where it is useful is with parameters you don't control...

In any case, so you are saying that if I have an integer parameter ($i) that may not be set, and I care about non-zero values, then:
!isset($i) || ($i == 0)
is faster than:
empty($i)

correct?
In reply to Mike Churchward

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
Yes it is faster... but with a slight change of syntax:

!isset($i) || ($i == 0) # slow, ambiguous, will do a cast
!isset($i) || ($i === 0) # fast, precise, no cast

Tim Hunt posted about this about 2 months ago. In any case, ou shouldn't trust me or Tim. Test it yourself. چشمک

> What I mean by 'isset()' not being needed, is that generally you should have variables initialized.

Well, you don't always get to initialise your own vars. Did you read has_cap_fad() as I was hinting? In that code, whether an array key exists -- regardless of value -- is significant.

The other thing is that you can use the semantic difference between NULL and a var not being set to indicate states you care about in your variables.
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
As requested, posting bugs here for you.

Some MYSQL issues on the latest version from just now:

MDL-11171 - MySQL doesn't like CAST AS INTEGER
MDL-11172 - MySQL syntax error when listing available courses

And some other things as I go along:

MDL-11173 - Rename has_cap_fad to has_capability_in_accessdata
MDL-11174 - is_site_admin() needs a global $USER

I'll be prefixing all the bug titles with "19PERF: " and I suggest everyone else does the same.


In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

I've pushed out the fixes for

MDL-11171 - MySQL doesn't like CAST AS INTEGER MDL-11174 - is_site_admin() needs a global $USER

I really cannot repro MDL-11172 - MySQL syntax error when listing available courses. And has_cap_fad() is pretty internal to accesslib... I'm not that keen on carpal tunnel just yet... لبخند

In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
> I'll be prefixing all the bug titles with "19PERF: " and I suggest everyone else does the same.

Better yet, please add them as subtasks to: MDL-11180
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Dan Poltawski در
One of the silly stats you missed out was from the commitdiff about forum cron: 864ad0cd7fbcaffb858343818488be9761cf7cbb

 With 1 forum post, sent total 24 times 
- Before 11 000 DB queries (approx) 
- After 506 DB queries 
With 6 forum posts, sent a total of 452 times 
- Before 47 876 DB queries 
- After 8 256 DB queries 
Presumably the vast quantities was related to vast numbers of users on in the moodle?
It leads me to wonder how/if we can programmatically spot these kind of issues to prevent them creeping up on us in the future. A way of extending unit testing to give us sanity checks. An automated build system with vast quantities of users? Cronjobs are exactly the type of problem which typically gets missed from standard user-orientated testing, particularly event-oreintated things like forum posts..

(Dan has 400 moodle crons run every 15 mins but has never spotted the 50 million queries which could potentially fly by! )
In reply to Dan Poltawski

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Great to get feedback from someone reading the code. Yes there are lots of "silly" stats, like login whic was taking 6K queries for some users, and now it takes 3, flat, for everyone. (I can't remember what it was scaling badly across -- I think number of courses and categories).

Presumably the vast quantities was related to vast numbers of users on in the moodle?

it is a combinatorial mess of

  • number of courses (~4)
  • number of users involved (~200)
  • number of discussions (~3)
  • number of posts (6)

Have a look at the code, it's a big series of 3 nested foreach()s. And all the work in the email formatting is done time and again -- filters are a major drag here. There is quite a bit of complexity in it, so pulling the work to the controlling loop isn't trivial. But it's doable.

And note that those numbers are with rcache disabled. With rcache enabled things were a bit better, but still pretty crazy. This whole thing could be driven by something along the lines of

  • 1 DB query to get the course/forum/disc/post data to loop over
  • 1 DB query per-course to get participants (only relevant if it's a forced-subscription forum)
  • 1 DB query per-forum that is not force-subbed
  • 2~3 DB queries to get accessdata for all the users
  • something smart to cache filter data without pointless DB work (a simple in-memory writethrough cache that only kicks in under cron perhaps?)
  • a queued smart way to mark the forum posts as read, perhaps via a temptable...

So a target for my case above would be perhaps... 20 DB queries? The main performance drag that we cannot avoid is the mark-as-read thingy.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
OK, so we're doing more testing on some of the permission resolution in the current version of the new code, specifically for the case where roles and overrides are mixed between two different levels of contexts.

For example, you might want to modify a role in a subcontext, or give someone a special role in the subcontext.

Here is a matrix of tests we've done related to this, using the mod/forum:addnews capability on a News forum in a course. The default roles have ALLOW for this in the teacher role, and no permission in the student role. The X's denote where permission resolution doesn't happen as it should (others have been tested and work fine):










Role assigned in News forum
Student
Teacher
None
No override
ALLOW
PREVENT
No override
ALLOW
PREVENT
No override
ALLOW
PREVENT
Role assigned in course







Teacher
PREVENT
-
-
-
-
-
-
-
-
-
ALLOW
-
-
X
-
-
X
-
-
X
No override
-
-
X
-
-
-
-
-
-

Student

PREVENT
-
X
-
-
X
-
-
X
-
ALLOW
-
-
-
-
-
X
-
-
-
No override
-
-
-
-
-
-
-
-
-
None


PREVENT
-
-
-
-
-
-
-
-
-

ALLOW
-
-
-
-
-
-
-
-
-

No override
-
-
-
-
-
-
-
-
-



In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Thanks for the testing grid. Together with the skype discussion, it points out that I had initially implemented a different set of rules. Namely, I wasn't honouring the "most local context wins".

Now it does (quick, grab the latest mdl19-perf), with the following notes (discussed in skype earlier today)...

Local-wins rule combines with RA-locality-before-RDef-locality

Local-wins rule is applied to both Role Assignments (aka RAs) and Role Definitions (aka RDefs)... however... locality of RAs trumps locality of RDefs. A teacher role-assignment at course (with an ALLOW permission set at course or higher) will trump a PREVENT permission override for the logged-in-user role (for which the user gets a ghost role-assignment sitewide) even if the override is in the forum.

This makes sense in most (all?) use cases -- for example if you want to apply a local PREVENT for guests/logged-in-users without penalising the course teacher -- who is always a logged-in-user too! Even if the rule for logged-in-users is more "local", the teacher RA locality is more important. People do think first of locality of RA

moodle/site:doanything trumps a PROHIBIT on a specific capability

If you call has_capability('foo'...) and doanything is true, has_capability() will check for moodle/site:doanything even if it hits a PROHIBIT in 'foo'.

Behaviour hasn't changed between HEAD and my code, but I don't think it's documented anywhere چشمک

We honour DENY/PROHIBIT on moodle/site:doanything

When checking whether the user has the fabled moodle/site:doanything , the code in mdl19-perf honours DENYs and PROHIBITs set against moodle/site:doanything.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
Great, all that looks much better now, thanks! بله

We're still working on some speed stats to compare the two methods on large and small sites, but I think we're getting close to merging this into HEAD!
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
Now that the features are pretty much equal, I've been doing some performance comparisons between 19PERF and HEAD.

These are some early impressions from today based on a direct comparison between two identical sites running on the same machine with only one user (me). The environment is MySQL 5 but only PHP 4. The vanilla sites have 200000 role assignments, 10000 courses and 20000 users. Most courses have one teacher, and an average of about 10 students. rcache is off. All the performance logging is on. Developer debugging is off. I'm doing a lot of reloading pages to get a "feel for it" and comparing things like first access vs subsequent access.

Database access is mostly going down from about 10% to 33% depending on the page. The biggest drop so far was visiting a big course for the first time in a session (down from 300 to 104) - on a second access the drop is less (132 -> 104). On an empty course database access actually goes up (69->86). More commonly the gains are around 20% in the good direction. لبخند

Page loading speed for me is mostly equivalent so far (whether logged in or not, or first access or not). Login is one thing that is noticeably snappier, (from about 2 seconds to 0.5).

RAM use has gone up very slightly on most pages (but it's neglible, like 10.4 to 10.5 Mb)

Overall it's looking good so far and worth getting into HEAD in the next day or two : the reductions in database access should help those with slow databases or a lot of users. approve We'll keep on testing on different sorts of sites (large and small) and other operations (I'm keen to see what cron looks like).

Thanks again for all your hard work, Martín! cool
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Great to hear it's going well!

While you were testing, I put some testing ideas together -- a bit of a hint of the areas I've focused on. There's a lot I haven't worked on directly, so...

On the pages that I considered bad cases, you should see on a "developer setup" things happening 3~4 times faster, I am thinking

  • Login for users with many courses (you've found it, I think چشمک )
  • Course listing if there are lots of course managers displayed
  • Course listings if there are thousands of courses

The main benefits aren't that visible on a single dev box...

Have fun with it!

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
Yes, we talked about the course listings before and they were the first things I tried but there weren't really any significant differences to HEAD on my set up.
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Quick test of homepage course listings. The database is an upgrade of the DB behind this http://courses.polhn.org/ site. First number is DB queries, 2nd number is time in seconds.

Homepage           [   HEAD+rc  ][   HEAD   ] [ m19-perf+rc ][ m19-perf ]                 
 - as admin           802 0.83     810 0.81        146 0.53     153 0.52
 - not logged in      242 0.56     268 0.51         73 0.30      80 0.29

In all cases, I performed several refreshes to ensure that filtered strings were taken from the filter cache and that the session stuff was setup already. The stats are taken on my laptop, over loopback, which mostly downplays latency in db queries.

In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Yes, we talked about the course listings before and they were the first things I tried but there weren't really any significant differences to HEAD on my set up.

I've figured out why -- the case I was thinking was with hidden categories. Try, as admin, browsing through the course listing of a category that is hidden. With 3221 courses, I get HEAD code with 3250 queries, mdl19-perf with 88.

In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

I am trying to repro some of the tests & numbers you posted because I haven't benchmarked it much on HEAD -- so I worry about mistakes in my rebasing of the patches. Or perhaps new code in HEAD that isn't using the handy context objects passed around, etc...

On an empty course database access actually goes up (69->86)

Puzzling. With an empty, just created course, I see roughly the same time, but half the DB queries.

           [   HEAD+rc  ][   HEAD   ] [ m19-perf+rc ][ m19-perf ]                 
                71 0.43      72 0.38       46 0.44      46 0.41

And we can chop the course page to a mostly-fixed 20 dbqueries if we want.

In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

A few testing ideas...

  • When you test the "before", if you are looking at PERF stats, make sure you have the patch that fixes PERF stats to happen in moodle_request_shutdown(). Otherwise, many important and heavy pages never get reported -- notably login.
  • A good test case is to run the DB on a separate machine. That's an area where 1.7/1.8 do particularly bad because they trigger hundreds of DBqueries, and the latency of having the DB on a separate box kills you. Doing the same job in fewer queries is a huge boost in this scenario.
  • A single DB server can normally deal with 4 or 5 webservers... so to test in this kind of split in a strictly non-scientific way, with a "bogged down" DB server, I run the DB with full query logging and a few other "slowdown" bits...
  • If you have a ton of courses, course listing in the category pages generates 1 DBq per course.
  • Similarly in course participants pages for courses with tons of users
  • Users with a few hundred courses (direct enrolment or indirect via a sitewide or category enrolment) have very heavy logins that walk thousands of contexts.
  • Those same users -- and admins -- end up with huge session files. Session file size is an important metric -- we were getting killed by the cost of unserialise() when the session was being read back in.
  • Test with and without rcache.
  • I didn't optimise much inside modules.
  • Test a homepage with a dozen courses listed, each with several course managers - something like http://courses.polhn.org/
  • While you are testing the mdl19-perf code, it's interesting to look at the "loading" debugging messages -- which I will of course remove.
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
> When you test the "before", if you are looking at PERF stats, make sure you have the patch that fixes PERF stats to happen in moodle_request_shutdown().

Where is that, shouldn't that be in head?
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Penny Leach در
Martin, I'm not clear on the difference between the last two, can you elaborate?
In reply to Penny Leach

Re: Catalyst performance patches for 19/HEAD

از Samuli Karevaara در
Some info here: http://docs.moodle.org/en/Manage_roles#Permissions

Basically Deny = lower levels can override, Prohibit = lower levels cannot override.
In reply to Samuli Karevaara

Re: Catalyst performance patches for 19/HEAD

از Penny Leach در
Sure, but I didn't mean the difference between prevent & prohibit چشمک

I meant the difference between:

moodle/site:doanything trumps a PROHIBIT on a specific capability

and

We honour DENY/PROHIBIT on moodle/site:doanything


which seem to be the opposite of each other (at least as far as the prohibit goes)
In reply to Penny Leach

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Yes, it's tricky to explain. Here we go with another try:

First -- I am documenting an "old" fact, that is that PROHIBITs on cap "foo" is ignored if the user has "moodle/site:doanything" for the context. The PHOHIBITS wins within the scope of that particular capability. And then -- before saying "no" -- we fallback on the check for "moodle/site:doanything".

Second... when we check for moodle/site:doanything we follow the standard rules for any capability. So if you have a role "mostlyadmin" that has a "moodle/site:doanything" at a categorylevel, that doanythingness can still be constrained by a "moodle/site:doanything"=CAP_PROHIBIT in a particular course or module in that category, via you have a different role or an override.

Probably old news too, but MartinD hinted that maybe the code in HEAD doesn't run those checks "in depth".

Clear as mud? Welcome to The Accesslib! Mbwahahaha.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Grab the latest mdl19-perf from HEAD

  • All the functionality bugs filed or mentioned have been fixed...
  • Fixed a few bugs during upgrades from 1.7/1.8 to HEAD

And I've landed the "better PERF logging" patches of the series, which don't touch accesslib. Will probably put them in 18_STABLE too.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Matthew Davidson در
عکس Core developers عکس Plugin developers
One of the tracker bugs that I worked on for a while is MDL-7416 and MDL-9238. I tried to implement a get_my_courses() alternative that used 1 all encompassing SQL statement and 1 db query as to the continuous loop with has_capability() calls. There are some noted performance improvements in there, but the last bit of logic that was missing in the SQL was what Petr referred to as role summing. Maybe you could look into this. My latest SQL is at the bottom of both bugs.
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
Hi all!

We are at a critical point where I need more testers/reviewers before the merge!

I am going to be trying to finish this off in the next couple of days and merge it. Other projects are starting to pull me in all sorts of directions, and hacking on this code needs quite a bit of focus (at least for me! others may be able to just read it and visualise all the implications of a change in the core of accesslib, I find it pretty hard).

As I'll soon be working on other stuff, and will loose that focus, dealing with bugs and change proposals will take quite a bit more work. So hurry now, while I still have it "in my head".

So -- testers/reviewers, hit it hard so I can address all anything you unearth.
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Anthony Borrow در
عکس Core developers عکس Plugin developers عکس Testers
Martin - Is this available on CVS or only GIT? I'd be willing to test with older production data but I'm not familiar with GIT and with classes I feel like I'm learning enough so I'm not anxious to learn about GIT. Peace - Anthony
In reply to Anthony Borrow

Re: Catalyst performance patches for 19/HEAD

از Iñaki Arenaza در
عکس Core developers عکس Documentation writers عکس Particularly helpful Moodlers عکس Peer reviewers عکس Plugin developers

I can generate patches for you, if you think it'll be easier. I'm already using git and tracking MartinL's repository, so this is just a couple of minutes at most.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Catalyst performance patches for 19/HEAD

از Tim Hunt در
عکس Core developers عکس Documentation writers عکس Particularly helpful Moodlers عکس Peer reviewers عکس Plugin developers
Probably the way to maximise testing is to make a tarball for download of the modified files based on the latest Moodle HEAD.

Martin, what further testing do you think is needed? Since we are 99% committed to releasing this in 1.9, why not just put it on head now, and maximise testing that way. This is probably naive, but I can't see why so I was hoping you could explain. Thanks.
In reply to Tim Hunt

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

Hi Tim,

merging into HEAD is a bit of a double-edge sword for complex code. Once things are in HEAD, and specially around the core where if something is broken, it affects all of Moodle, there is a "HEAD-rush" effect: all the core team wants to fix it, quick. The first patch -- not the best, not even the "right" patch -- wins.

This code I've written is fairly disruptive and when I am working on it, it requires quite a bit of concentration, else the patch will fix one thing and break 7, and I'll have to revert it and rethink the fix. You don't see but there was a ton of rework on my private branch -- 30%~40% of the code I discarded. I know -- it all sounds pretty pretentious, but I found it pretty hard. Perhaps everyone else finds it trivial, in the meantime, I'm being very conservative.

Code that needs careful thinking and an approach of try a patch, show it, discuss it, test it and then decide to keep it or not, perhaps taking several days on that process... just isn't a good fit for development (or debugging!) in CVS HEAD. In fact, one of the key things I am hoping we can agree on is that development and bugfixing on accesslib and related bits should happen on a "draft" branch using git or mercurial, at least for a while.

In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Tim Hunt در
عکس Core developers عکس Documentation writers عکس Particularly helpful Moodlers عکس Peer reviewers عکس Plugin developers
Thanks for explaining.

And even bigger thanks for actually working this out. I certainly do not underestimate how hard it was.

Of course, this would be a prime area of the code for unit tests - when anyone has a spare moment.
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
Yep, but I think we're OK to go ahead in HEAD now, though. Quite a lot has been found and fixed in the past couple of weeks and it's looking like there are no major gotchas remaining. In addition, this is now holding up other work. Can you check it into HEAD today / tomorrow please? Thanks!
In reply to Martin Dougiamas

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
That's what I've been working towards چشمک

Your "yes"... does it mean we can agree on having a go-slow peer-review'd approach on accesslib and related bits and pieces...?
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Martin Dougiamas در
عکس Core developers عکس Documentation writers عکس Moodle HQ عکس Particularly helpful Moodlers عکس Plugin developers عکس Testers
I've agreed with you (4 or more times now) that accesslib-related stuff is definitely very delicate, and that all significant changes should be posted as patches for general discussion and testing first (we already do this for lots of stuff). Regardless of this issue, it's a lot more efficient for most of us to work with CVS than git.

I'm not sure what you're looking for ... are you asking to personally review and vet every single change to anything related to accesslib from now on? How many peers are you talking about? I'd be ecstatic if you want to continue testing and working on accesslib issues, assuming you have time.
In reply to Tim Hunt

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در

what further testing do you think is needed?

On this track --

There's a lot of testing around correctness of the new accesslib (Yu has found some good bugs around tricky cases). Things like the just-in-time accessdata loading need a bit of testing.

And second, there's a lot of measuring and finding of bottlenecks that I haven't spotted yet. MartinD managed to hit one with the calendar block. And there's a similar one open too.

Have a look at the bugs listed under the meta bug MartinD created here http://tracker.moodle.org/browse/MDL-11180 and at the last dozen or so patches I've applied.

If anyone wants to play with it in git, I've pushed the same branch to repo.or.cz under "moodle-pu" ("proposed updates") so people can play and also push commits to the branch for discussion (and eventually merging).

In reply to Anthony Borrow

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
By popular request چشمک

This link will give you always a tar.gz of the latest version of the mdl19-perf branch
http://git.catalyst.net.nz/gitweb?p=moodle-r2.git;a=snapshot;h=mdl19-perf

Note: the link to "snapshot" in the gitweb navigation for some reason always links to the "HEAD" version, so it's buggy. So use the link I mention above.
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Anthony Borrow در
عکس Core developers عکس Plugin developers عکس Testers
Using the above link, I downloaded and began working with production data from a 1.8 install. After attempting to login I receive:

Fatal error: Call to a member function RecordCount() on a non-object in /home/arborrow/Moodle/code/19perf/lib/accesslib.php on line 1155
In reply to Anthony Borrow

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
Rather than attempt to login, hit /admin directly. It should work. See this exchange between MD and me about it: http://moodle.org/mod/forum/discuss.php?d=79455#p353054
In reply to Martín Langhoff

Re: Catalyst performance patches for 19/HEAD

از Anthony Borrow در
عکس Core developers عکس Plugin developers عکس Testers
Martin - OK - I was able to get the upgrade process started. Will report back with anything else I find. Peace - Anthony
In reply to Anthony Borrow

Re: Catalyst performance patches for 19/HEAD

از Wen Hao Chuang در
Cool, I just did the same thing too and will report back with anything else I could find. Thanks all!

By the way somehow the server that is hosting the moodle-r2.git-mdl19-perf.tar.gz is really slow. I'm getting 14 - 16 KB/sec on my T1 connection. Just a quick FYI
In reply to Wen Hao Chuang

Re: Catalyst performance patches for 19/HEAD

از Martín Langhoff در
Great to have some testers but... hurry up! Actually, the code in git is no longer the latest. The latest is in CVS HEAD now. Did you see this thread? http://moodle.org/mod/forum/discuss.php?d=80475

OTOH, the git server is fine, but it's in NZ چشمک I've also been pushing the branch to repo.or.cz which might be faster. If you really want the GIT repo, http://repo.or.cz/w/moodle-pu.git?a=snapshot;h=mdl19-perf;sf=tgz