Bug 28172 - Optimize Koha::Plugins::GetPlugins
Summary: Optimize Koha::Plugins::GetPlugins
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Julian Maurice
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 7923
  Show dependency treegraph
 
Reported: 2021-04-20 07:15 UTC by Julian Maurice
Modified: 2024-07-04 20:37 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 28172: [DO NOT PUSH] Test script for GetPlugins (1.60 KB, patch)
2021-04-20 07:16 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 28172: Optimize Koha::Plugins::GetPlugins (4.86 KB, patch)
2021-04-20 07:16 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 28172: [DO NOT PUSH] Test script for GetPlugins (1.60 KB, patch)
2022-11-02 08:50 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 28172: Optimize Koha::Plugins::GetPlugins (3.68 KB, patch)
2022-11-02 08:50 UTC, Julian Maurice
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Maurice 2021-04-20 07:15:02 UTC

    
Comment 1 Julian Maurice 2021-04-20 07:16:03 UTC
Created attachment 119870 [details] [review]
Bug 28172: [DO NOT PUSH] Test script for GetPlugins
Comment 2 Julian Maurice 2021-04-20 07:16:07 UTC
Created attachment 119871 [details] [review]
Bug 28172: Optimize Koha::Plugins::GetPlugins

Instead of doing one SQL query for retrieving a list of plugin classes
(filtered or not by a method name) + one SQL query for each loaded
plugin (to look up the 'enabled' status), we can do a single SQL query,
fetching only enabled plugins, and do the method check using `can`.

It allows to use the Module::Load::Conditional cache when requesting
only enabled modules, which gives a great performance boost

Also, call get_metadata only if needed

Test plan:
1. Make sure you have some plugins enabled
2. Apply the 1st patch ("Test script for GetPlugins")
3. Run the test script several times, copy each result into a file A
4. Apply the other patch(es)
5. Run the test script several times, copy each result into another
   file B
6. Compare the results. Times in file B should be smaller than in file A
Comment 3 Julian Maurice 2021-04-20 07:19:38 UTC
Without the patch:

% ./test_getplugins.pl 
2 plugins detected, 2 enabled
First 2 calls to GetPlugins: 0.533s
1000 calls to GetPlugins: 3.505s
1000 calls to GetPlugins with method = "unknown_method": 0.824s
1000 calls to GetPlugins with all = 1: 3.580s

With the patch:

% ./test_getplugins.pl
2 plugins detected, 2 enabled
First 2 calls to GetPlugins: 0.535s
1000 calls to GetPlugins: 1.502s
1000 calls to GetPlugins with method = "unknown_method": 0.730s
1000 calls to GetPlugins with all = 1: 3.795s
Comment 4 David Nind 2022-11-01 00:05:39 UTC
The patch no longer applies :-(..
Comment 5 Fridolin Somers 2022-11-01 02:23:23 UTC
Arf not a trivial rebase.
I leave it to Julian ;)
Comment 6 Julian Maurice 2022-11-02 08:50:03 UTC
Created attachment 142917 [details] [review]
Bug 28172: [DO NOT PUSH] Test script for GetPlugins
Comment 7 Julian Maurice 2022-11-02 08:50:09 UTC
Created attachment 142918 [details] [review]
Bug 28172: Optimize Koha::Plugins::GetPlugins

Instead of doing one SQL query for retrieving a list of plugin classes
(filtered or not by a method name) + one SQL query for each loaded
plugin (to look up the 'enabled' status), we can do a single SQL query,
fetching only enabled plugins, and do the method check using `can`.

It allows to use the Module::Load::Conditional cache when requesting
only enabled modules, which gives a great performance boost

Also, call get_metadata only if needed

Test plan:
1. Make sure you have some plugins enabled
2. Apply the 1st patch ("Test script for GetPlugins")
3. Run the test script several times, copy each result into a file A
4. Apply the other patch(es)
5. Run the test script several times, copy each result into another
   file B
6. Compare the results. Times in file B should be smaller than in file A
Comment 8 Julian Maurice 2022-11-02 08:57:08 UTC
Rebased on master, but now when running the test script I get a really bad time for "1000 calls to GetPlugins with all = 1".

As bug 29672 changes Koha::Plugins::call so that it does not use GetPlugins, I'm not sure if this patch is still relevant.
Comment 9 Katrin Fischer 2023-07-01 08:18:54 UTC
(In reply to Julian Maurice from comment #8)
> Rebased on master, but now when running the test script I get a really bad
> time for "1000 calls to GetPlugins with all = 1".
> 
> As bug 29672 changes Koha::Plugins::call so that it does not use GetPlugins,
> I'm not sure if this patch is still relevant.

Hi Julian, should we close this now that bug 29672 is pushed?
Comment 10 David Nind 2023-08-15 10:15:52 UTC
Changed status - fixed on bug 29672.