Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(autoloader): Drop legacy class autoloader #36114

Merged
merged 1 commit into from
Mar 16, 2023

Conversation

ChristophWurst
Copy link
Member

@ChristophWurst ChristophWurst commented Jan 12, 2023

  • Resolves: n/a

Summary

The documentation says apps should use PSR-4 to get their classes loaded. The legacy PSR-0 is still in place and has a negative impact on performance.

  1. PSR-4 autoloading was introduced in PSR-4 for apps owncloud/core#24386
  2. App autoloader support was added in Allow apps to have their own autoloader #6853
  3. Our documentation says app should use PSR-4 https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/classloader.html. PSR-0 (legacy) is not even mentioned.

PSR-0 was deprecated in 2014: https://www.php-fig.org/psr/psr-0/. Our docs also list it as deprecated: https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/psr.html#psr-0-autoloading

This is a hard breaking change for the apps that have not yet been upgraded to PSR-4. Therefore I would suggest to warn about this in the 26 upgrade docs and drop the loader only with Nextcloud 27 or later. @AndyScherzinger @PVince81 your call.

Benchmarks

time for i in `seq 1 100`; do php occ; done

Before

real 0m53,323s
user 0m46,178s
sys 0m6,851s

After

real 0m49,161s
user 0m42,581s
sys 0m6,555s

^ that is 7.8% speedup for a generic Nextcloud process

Checklist

@ChristophWurst ChristophWurst added 0. Needs triage Pending check for reproducibility or if it fits our roadmap technical debt performance 🚀 labels Jan 12, 2023
@ChristophWurst ChristophWurst self-assigned this Jan 12, 2023
@nickvergessen nickvergessen added this to the Nextcloud 26 milestone Jan 12, 2023
@nickvergessen nickvergessen added 3. to review Waiting for reviews and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Jan 12, 2023
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

👍 cool!

@PVince81 PVince81 added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jan 12, 2023
@PVince81
Copy link
Member

it's still early enough. if we kill this for NC 26 we then need to communicate this as soon as possible on the forum with instructions how to migrate

a question also is how difficult it is, whether it's just an hour of work or requires rewriting of things

@ChristophWurst
Copy link
Member Author

a question also is how difficult it is, whether it's just an hour of work or requires rewriting of things

It's about renaming php class files. The effort depends on the number of files that need a rename.

@nickvergessen nickvergessen added the pending documentation This pull request needs an associated documentation update label Jan 12, 2023
Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

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

Is it faster because it’s faster or because some classes are not loaded anymore?
How certain are we this is not used in core?

@ChristophWurst
Copy link
Member Author

Is it faster because it’s faster or because some classes are not loaded anymore?
How certain are we this is not used in core?

That is an absolutely fair point

But CI is quite happy and I believe we migrated all PSR0 files to PSR4 at some point. It was a series of PRs by @nickvergessen and @rullzer.

@nickvergessen
Copy link
Member

nickvergessen commented Jan 12, 2023

How certain are we this is not used in core?

I guess there is only one way to find out: 🍿
But yeah, we moved almost everything back then I guess. I would say check back on files_sharing and files_external, that could be the non-default points still using old tech as automigration failed, but I think all was done back then

@AndyScherzinger
Copy link
Member

This is a hard breaking change for the apps that have not yet been upgraded to PSR-4. Therefore I would suggest to warn about this in the 26 upgrade docs and drop the loader only with Nextcloud 27 or later.

As suggested by Christoph, let's warn with 26 and drop on master after release of v26 that should give everyone enough time to upgrade or fix respectively, including us on core/server if needed.

@ChristophWurst ChristophWurst added 2. developing Work in progress and removed 4. to release Ready to be released and/or waiting for tests to finish labels Jan 13, 2023
@ChristophWurst ChristophWurst marked this pull request as draft January 13, 2023 11:59
@ChristophWurst
Copy link
Member Author

let's warn with 26

PR at nextcloud/documentation#9553

@ChristophWurst
Copy link
Member Author

It's showtime

@ChristophWurst ChristophWurst marked this pull request as ready for review March 3, 2023 12:04
@ChristophWurst ChristophWurst added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Mar 3, 2023
@szaimen
Copy link
Contributor

szaimen commented Mar 16, 2023

/rebase

The documentation says apps should use PSR-4 to get their classes
loaded. The legacy PSR-0 is still in place and has a negative impact on
performance.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@DaphneMuller
Copy link

Hello!
Thank you for your work on this! I noticed that your PR still has the label 'documentation'. I'm not sure if you already had a look at the documentation for your PR, but at Nextcloud we strive to document changes that affect other app developers or other admins before the release takes place, and I'm pinging you with the hope to get this done.

Are you familiar with our documentation process already?
Changes that affect app developers should be documented here:
https://docs.nextcloud.com/server/27/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_27.html

Changes that affect administrators should be documented here:
https://docs.nextcloud.com/server/latest/admin_manual/release_notes/upgrade_to_27.html

While I understand sometimes it's handy to merge fast to get your changes in, it would be great if next time you could try to add the documentation before merging. You can find more information on that here:
https://docs.nextcloud.com/server/27/developer_manual/prologue/compatibility_app_ecosystem.html#documentation-procedures-of-changes-that-affect-app-developers

If all your documentation efforts are done, please remove the label 'documentation' and check the checkbox in your opening note and I'll stop bugging you :)

Many thanks in advance and thanks again for your work!

@nickvergessen
Copy link
Member

Documentation is in nextcloud/documentation#10231

@ChristophWurst ChristophWurst removed the pending documentation This pull request needs an associated documentation update label May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

7 participants