craftcms / craftcms/cms

[4.x]: (large) site becomes unusable due to generating project config YAML files

Open
#14,140 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug craft4
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?

I've noticed an issue with project config for some time now, and it's really noticeable for large sites. In this context, this is for one of the test sites we (Verbb) use for development, so we really put Craft through its paces with lots of fields, sections, entry types, and content rows - so it's a good test case. And with 50+ plugins of ours to test, there's lots of stuff we need!

Now, that might not be a real-world case, but it certainly brings up a noticeable issue, and that's generating the project config YAML files. When disabling every plugin, my local server will timeout trying to create these files. It's at the point where I have to disable the generation of the YAML files with:

'components' => [
    'projectConfig' => function() {
        $config = craft\helpers\App::projectConfigConfig();
        $config['writeYamlAutomatically'] = false;
        return Craft::createObject($config);
    },
],

You can see in this video that the process stalls without even getting to the end.

What's more, I noticed that even on a smaller site with less data, the project config is rebuilt multiple times. See this video. Here, I've extended the timeout to illustrate the issue, but even I run out of patience waiting for it to finish 😁

You'll notice I'm not even making any changes, just loading the control panel to trigger the YAML files to be generated. It's incredibly slow on its own - I'm not exactly sure why? Sure, disk I/O is an expensive process, but this seems to be very slow to generate files. Understandably, when generating it multiple times, things may fall over, but it can barely get through one round.

I'm using MAMP, and while - yes - there might be better options out there - I've found it generally much faster than Docker, Valet, etc. I don't think it's an issue with my local environment, but happy to be proven wrong.

I'm more than happy to send through the database and project files, as they are just local testing stuff. Just let me know! I'd firstly like to see if this is just an issue for me, expected behaviour or something you've also noticed.

Craft CMS version

4.6

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the slowdown on a large site with automatic project-config writing enabled, then inspect the projectConfig component configured through craft\helpers\App::projectConfigConfig(). Compare the repeated generation triggered by loading the control panel with generation disabled. Done means project-config YAML generation completes without repeated rebuilds or request timeouts.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.