Skip to content

perf: Speed up fetching services from container - #64172

Draft
come-nc wants to merge 8 commits into
fix/cleanup-server-containerfrom
perf/short-circuit-aliases
Draft

perf: Speed up fetching services from container#64172
come-nc wants to merge 8 commits into
fix/cleanup-server-containerfrom
perf/short-circuit-aliases

Conversation

@come-nc

@come-nc come-nc commented Sep 10, 2026

Copy link
Copy Markdown
Contributor
  • Resolves: #

Summary

Speed containers lookup by:

  • Storing aliases in a raw array instead of relying on a closure in the container
  • Removed useless checks
  • Avoid relying on an exception throwing for a common usecase

Checklist

AI (if applicable)

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

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc self-assigned this Sep 10, 2026
@come-nc come-nc added the 2. developing Work in progress label Sep 10, 2026
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
$this->has will almost always return true as it checks class_exists and
 also $this->server->has, so the if made no sense.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Building an exception object can be expensive, avoid building one only
 to fallback to server DI from applications.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc added this to the Nextcloud 36 milestone Sep 10, 2026
@come-nc come-nc changed the title fix: Short-circuit aliases to avoid querying container for this perf: Speed up fetching services from container Sep 10, 2026
@come-nc
come-nc added this pull request to stack #64192 September 10, 2026 15:09
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc

come-nc commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

I think the flat array for aliases cannot work, at least not how I implemented it here.
Each container (one for server and one per application) may have its own aliases.
So the alias should be resolved at the last minute, before calling pimple container, never earlier. I’ll have to see if this can be done without too much trouble.
The rest of the changes are not impacted I believe.

I’m not sure whether this is the good solution.
What I’m not sure about is interactions between server and app
containers when there are aliases, which may not be the same on all of
them.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc

come-nc commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

I think the flat array for aliases cannot work, at least not how I implemented it here. Each container (one for server and one per application) may have its own aliases. So the alias should be resolved at the last minute, before calling pimple container, never earlier. I’ll have to see if this can be done without too much trouble. The rest of the changes are not impacted I believe.

I’m actually unsure, I pushed a commit going the other direction for now, I’ll look into this more in-depth later.
To be rock-solid we’d need a test for this, with aliases both on server and app container and see if it works. Or we need to edict some rules about this.

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.

2 participants