- Issue created by @deviantintegral
- Merge request !6145Add a basic static cache on getRemovedPostUpdates() β (Closed) created by deviantintegral
- π¨π¦Canada deviantintegral
I'm kind of amazed tests are passing. With that in mind, I've rebased against 11.x, though this patch applies cleanly to several prior Drupal versions as well.
I haven't added new tests, because this feels like exactly the sort of thing that should be transparent to calling code.
- Status changed to Needs review
11 months ago 7:48pm 12 January 2024 - Status changed to Needs work
11 months ago 7:59pm 12 January 2024 - First commit to issue fork.
- Status changed to Needs review
11 months ago 1:16pm 14 January 2024 - πΊπ¦Ukraine taraskorpach Lutsk πΊπ¦
I've updated the MR based on the comments. I've also added change records. Since this is my first time doing this, it would be better to have it reviewed.
- Issue was unassigned.
- Status changed to RTBC
11 months ago 2:12pm 15 January 2024 - π¨π¦Canada deviantintegral
I made some minor changes to the CR formatting, as I believe we use human-readable sentences. Otherwise, the code changes look good!
- πΊπ¦Ukraine taraskorpach Lutsk πΊπ¦
Hope it's okay within the Drupal community to interrupt in the middle of resolving an issue and make some MR changes. I just wanted to save you some time :)
- π¨π¦Canada deviantintegral
Totally, I forgot to unassign it for the weekend anyways.
- Status changed to Needs work
11 months ago 2:50pm 15 January 2024 - π¬π§United Kingdom catch
I think we we can improve things further by moving the caching down a level - see comment on the MR.
- Status changed to Needs review
11 months ago 7:33pm 15 January 2024 - π¬π§United Kingdom catch
It'd be worth comparing the detail for ::scanExtensionsAndLoadUpdateFiles() with the two approaches - if we're also checking update hooks during install (which we should be), then we should see savings from that which we won't see when comparing getRemovedPostUpdates()
- π¨π¦Canada deviantintegral
Here's three different profiles testing against Umami. These all compare against a base of
b1fbff58cca271a88373115ceb3a818bff1762d2
which is on the 11.x branch.First: comparing against
5605d11412
from this merge request. This is the first pass with a cache just aroundgetRemovedPostUpdates()
:Overall pretty decent, a 2% reduction in time and ~182K less function calls.
Second: comparing against
c30cc7f014
which moves the cache toscanExtensionsAndLoadUpdateFiles()
. While there's still around 182K less function calls, it actually took ~455ms more CPU time.I was curious and wondered if the additional calls to delete() needed when caching that whole function were related. So here's a third comparison against
5605d11412
with the additional call to clear caches as needed to pass tests when cachingscanExtensionsAndLoadUpdateFiles()
.As we can see, the additional delete() calls clearly have an effect.
With the above in mind, I think we should go with the first approach where we just cache
getRemovedPostUpdates
. While the second approach may be conceptually better, in all cases so far it seems to be slower than the first approach, both in a small install profile like Umami and in a much larger install profile. - π¬π§United Kingdom catch
I think I might have found an issue in the new caching logic - see comment on the MR.
- Status changed to Needs work
11 months ago 2:08pm 17 January 2024 - πΊπΈUnited States smustgrave
Appears to be 1 open thread, have not reviewed or tested.
- Status changed to Needs review
11 months ago 7:16pm 17 January 2024 - π¬π§United Kingdom alexpott πͺπΊπ
This is at least major. Fixing this will speed up site installs loads.
- π¬π§United Kingdom catch
There's only one failure in https://git.drupalcode.org/issue/drupal-3414349/-/jobs/664042 - so things might be close with the current approach?
- Merge request !6273Refactor update discovery to optimise when you are looking for a single extension β (Open) created by alexpott
- π¬π§United Kingdom alexpott πͺπΊπ
I've just opened up a new MR that refactors UpdateRegistry a bit. I no longer scans for all update functions for all extensions when doing getUpdateFunctions()... it only looks are update functions for the provided $extension_name.
It also static caches if calls loadUpdateFile() for a particular extension / root /site / update type combination and then does not redo work in scanExtensionsAndLoadUpdateFiles() because once a file is included in PHP it cannot change and it cannot be unloaded.
I've got a legacy site where I've applied this MR and π Configuration being imported by the ConfigImporter sometimes has stale original data Fixed (which also has a big impact on what happens in \Drupal\Core\Update\UpdateRegistry::onConfigSave() and this results in the follow xphrof changes...
This MR is responsible for:
- Status changed to Needs work
11 months ago 2:47pm 25 January 2024 - πΊπΈUnited States smustgrave
There are 2 MRs, 1 all green and 1 with a test failure, which one is to be reviewed?
- π¨π¦Canada deviantintegral
Nice! I like that we can go back to a simple static variable, I hadn't thought about the fact that PHP won't reload files once loaded. This also saves Drush from having to coordinate a release around this change (not that it's core's responsibility, but it's nice to save downstream users work even for constructor changes).
https://github.com/drush-ops/drush/blob/1f9e78ad1aace1efa26bbaaa2e30c628...
- Status changed to Needs review
11 months ago 4:56pm 31 January 2024 - πΊπΈUnited States smustgrave
Do wonder if a performance test should be added for this.
- π¬π§United Kingdom catch
To add performance testing for this we'd need to be able to count function calls via zend_observer which requires a PHP extension. This is not out of the question and something I'd love us to be able to do eventually, but it'd be a completely new thing compared to the current performance testing and quite a lot of work to set up.
- π¬π§United Kingdom alexpott πͺπΊπ
I deleted the CR because it was no longer relevant to the new approach. This would be great to land.
- Status changed to RTBC
11 months ago 6:33pm 5 February 2024 - πΊπΈUnited States smustgrave
Seems all feedback has been addressed then
@catch if you think it's worth it I can open a follow up for the testing.
Would say this may fall under a task maybe but will leave as is.
- Status changed to Fixed
11 months ago 6:52pm 5 February 2024 - π¬π§United Kingdom catch
@smustgrave I don't think we've got an issue open for counting function calls, but it would be good to have one yeah, would probably need to be a plan since it'd be a multi-step thing.
MR looks good and don't have any comments, so committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!
- πΊπΈUnited States smustgrave
Opened π± Possible meta around performance testing of function calls Active
Automatically closed - issue fixed for 2 weeks with no activity.