-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
When benchmarking the login page of NextCloud, I found out it was extremely slow, about 12 requests / second on my laptop, compared to around 380 requests / second on the login page of another PHP app I'm developing.
The login page is making 29 SQL requests, and is loading 768 files of PHP code (!).
When watching what's going on with Xdebug profiler I can see that classLoader::loadClass from Composer is executed more than 14.000 times and is taking 13% of the execution time. That's a lot. Most of the time it doesn't do much as the required file is not part of this composer instance (as all projects have their own composer loader). It seems that there are dozens of composer loaders registered, and every one is called until the correct project loader is found. For each of the 700 included files.
I tried writing a short autoloader that will just store a cache of all files and have only one instance (see attached patch). It's just a proof of concept, not a ready-to-implement patch (hence why the bug report and not a PR).
0001-Alternative-autoloader.patch.gz
This is a very simple and nave approach, just to see the impact it has.
With it I get only 752 calls, and it is now only using 3.5% of the execution time.
It's likely that there are better options out there, but this was just a quick test and a pointer on a place where NextCloud performance could be made better. Even though it should be questioned why a simple login page is doing so many requests and loading so many unrelated classes.
Steps to reproduce
--
Expected behavior
--
Installation method
None
Nextcloud Server version
25
Operating system
None
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
No response
List of activated Apps
No response
Nextcloud Signing status
No response
Nextcloud Logs
No response
Additional info
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status