Skip to content

First load VERY slow because of the translations #118

@maximehuran

Description

@maximehuran

Preview Issue : Sylius/Sylius#10269
I didn't check if it was corrected but I don't want to loose it.

Sylius version affected: 1.2.4

Newer versions should be impacted.

Description

The first load of sylius is crazy slow.

Steps to reproduce

Put 22k files into your theme, in many directories (like a node_modules/).

Possible Solution

The function which is causing the "issue" is:

\Sylius\Bundle\ThemeBundle\Translation\Finder\TranslationFilesFinder::findTranslationFiles

    public function findTranslationFiles(string $path): array
    {
        $themeFiles = $this->getFiles($path);

        $translationsFiles = [];
        foreach ($themeFiles as $themeFile) {
            $themeFilepath = (string) $themeFile;

            if (!$this->isTranslationFile($themeFilepath)) {
                continue;
            }

            $translationsFiles[] = $themeFilepath;
        }

        return $translationsFiles;
    }

We found out that trying to find all the translation files in a node_modules/ directory can be very painful.

The discussion on Slack starts here: https://sylius-devs.slack.com/archives/C5K44R5GU/p1553722188005300

A related PR: Sylius/Sylius#9013

Some solutions:

  • Cache the translations during warmup
  • Add a depth to the finder
  • Detect node_modules/ because this is the main scenario…

The good thing is that we can implement all these solutions and it will be amazing!

Thank you 💪 ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions