Create a faster autoloader

Created on 11 June 2015, over 9 years ago
Updated 15 September 2024, 3 months ago

Follow-up to #2501989: [meta] Page Cache Performance

Problem/Motivation

The autoloader takes up to 500 us overall to just load and register namespaces, which is 10% of page cache response time. (5 ms)

Needless work, because lots of what makes it "slow" is work that can be done at:

a) Composer autoloader creation time
b) At container compilation / dump time

Proposed resolution

- The ClassLoader.php is already created dynamically.

Add a composer script hook for after autoloader creation to:

- Provide a ClassLoaderDrupal.php with a ClassLoaderDrupalInterface

which has all the classmap, PSR-4 namespaces, etc. already registered as variables => 1 load call, opcode cached, no run-time overhead.

- Add internal APC support that is enabled once the prefix key has been set.
- Create a faster interface to add PSR-4 namespaces with pre-compiled prefix lengths in one go => 1 call to register all namespaces of all modules

If the class loader is not of that interface => use the old way => no BC break

---

Is that providing our own solution? yes

Could it live upstream? For sure, wonder why they don't do it like that from the start ...

Lets also open an issue to solicit feedback ...

Remaining tasks

- Do it, benchmark it

User interface changes

- None

API changes

- Use a hybrid of composer class loader / APC classloader and some newly defined functions.

📌 Task
Status

Postponed: needs info

Version

11.0 🔥

Component
Other 

Last updated about 2 hours ago

Created by

🇩🇪Germany Fabianx

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    Has this been resolved in the past 10 years?

    This may be closed after three months if there are no comments to clarify what else needs to be done.

Production build 0.71.5 2024