Remove ExtensionParser::scanDirectory() FileCache usage or share it with InfoParser

Created on 27 November 2024, 21 days ago

Problem/Motivation

While profiling and testing πŸ“Œ Add a core FileCache implementation that is database-backed Active , we noticed that extension parser runs on almost as many files as InfoParser and both have a separate FileCache, but extension parser just reads the file and does a single regex on it, that's barely slower than the work that FileCache does anyway.

with test discovery on and a few extra contrib modules:

> select substring_index(replace(cid, 'PREFIX:', ''), ':', 1) as cid_prefix, count(*) from database_file_cache group by cid_prefix;
+---------------------------------+----------+
| cid_prefix                      | count(*) |
+---------------------------------+----------+
| attribute_discovery             |      364 |
| container_yaml_loader           |       37 |
| extension_discovery             |      823 |
| help_topic_discovery            |       85 |
| hook_implementations            |       65 |
| info_parser                     |      811 |
| library_parser                  |        5 |
| procedural_hook_implementations |       75 |
| yaml_discovery                  |       89 |
+---------------------------------+----------+

With just core and without test discovery:

+---------------------------------+----------+
| cid_prefix                      | count(*) |
+---------------------------------+----------+
| attribute_discovery             |      492 |
| container_yaml_loader           |       33 |
| extension_discovery             |      109 |
| help_topic_discovery            |       85 |
| hook_implementations            |       64 |
| info_parser                     |       99 |
| library_parser                  |       12 |
| procedural_hook_implementations |       68 |
| yaml_discovery                  |      116 |
+---------------------------------+----------+

Also attaching a pdf of the xhprof report Remove ExtensionParser::scanDirectory(). Most of the work is in the iterators and discovering the files, the only bits we cache are file open, file read, preg_match and so on.

Steps to reproduce

Proposed resolution

Drop the FileCache.

Alternatively, an option might be to use the InfoParser instead of reimplementing a custom optimized parser, to share the file cache if we're going to need it anyway. Only a handful of extra files are read by ExtensionParser that aren't by InfoParser (profiles maybe?) Might be worth investigating if InfoParser is really needed that often. Maybe that could be done lazy or only on enabled extensions or something like that.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.1 πŸ”₯

Component

base system

Created by

πŸ‡¨πŸ‡­Switzerland berdir Switzerland

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024