Skip to content

perf: Only sort wrappers when adding them#61438

Open
CarlSchwan wants to merge 1 commit into
masterfrom
carl/usort-storagefactory
Open

perf: Only sort wrappers when adding them#61438
CarlSchwan wants to merge 1 commit into
masterfrom
carl/usort-storagefactory

Conversation

@CarlSchwan

Copy link
Copy Markdown
Member

Instead of doing that each time a new mount point is created (e.g. for the 7000 shares we have in production).

  • Resolves: #

Summary

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@CarlSchwan CarlSchwan self-assigned this Jun 19, 2026
@CarlSchwan CarlSchwan requested a review from a team as a code owner June 19, 2026 10:16
@CarlSchwan CarlSchwan requested review from ArtificialOwl, icewind1991, leftybournes and salmart-dev and removed request for a team June 19, 2026 10:16
@CarlSchwan CarlSchwan added this to the Nextcloud 35 milestone Jun 19, 2026

@salmart-dev salmart-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Altahrim

Copy link
Copy Markdown
Collaborator

Does it worth sorting them only when needed?

Add some kind of dirty flag: when a wrapper is added, dirty is switched to true. When we need a wrapper. If dirty is true, we sort wrappers and set flag to false again.

@CarlSchwan CarlSchwan force-pushed the carl/usort-storagefactory branch from 2f30a6f to fc4bfa3 Compare June 23, 2026 09:02
@CarlSchwan

Copy link
Copy Markdown
Member Author

Does it worth sorting them only when needed?

Add some kind of dirty flag: when a wrapper is added, dirty is switched to true. When we need a wrapper. If dirty is true, we sort wrappers and set flag to false again.

done. Not sure that improves that much the perf as the list of wrappers is very small, but it is also a very simple change that doesn't make the code much more complex

Instead of doing that each time a new mount point is created (e.g. for
the 7000 shares we have in production).

Signed-off-by: Carl Schwan <carlschwan@kde.org>
@CarlSchwan CarlSchwan force-pushed the carl/usort-storagefactory branch from fc4bfa3 to a6f432f Compare June 23, 2026 13:56
@@ -44,6 +47,7 @@ public function addStorageWrapper(string $wrapperName, callable $callback, int $
*/
public function removeStorageWrapper(string $wrapperName): void {
unset($this->storageWrappers[$wrapperName]);
$this->dirty = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unset should not change the order 🤔

@salmart-dev

Copy link
Copy Markdown
Contributor

🤦 I implemented again the same thing forgetting I had even reviewed this one.

I did it a bit differently, keeping the references of sorted wrappers in memory, so we wouldn't need to keep doing array operations at every wrap. Since wrap is called often with many shares, it may be worth keeping the extra cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants