Prestashop: [Performance] Prestashop 1.7 front very slow with translation

Created on 7 Jan 2019  路  7Comments  路  Source: PrestaShop/PrestaShop

Describe the bug:
Hello,

As part of the development of a Prestashop B2B, we note since our migration 1.6 to 1.7 of big falls of performance on the front.
We have investigated and we come to the following observation, the problem comes from the getTranslatorFromLocale ($ locale) function of Context.php.

So we have several questions for developers:

  • Why did you choose to delete and recreate the cache files each time the function is called? The number of disk writes is huge.
  • I see that when a Symfony Message is found, then it is returned directly, is it possible to use this principle for the front?
  • Have you planned a redesign of this feature in an upcoming update?

We have implemented many B2B functions (fast order entry, basket models, multi-user accounts, collaborative purchase lists, etc ...), and our application is strongly impacted by performance: /

Thanks for your help,

Additionnal information:
PrestaShop version: 1.7.4.3
PHP version: 7.1.23
Working environment: Windows 10 with Apache 2.4

1.7.4.3 Bug FO No change required

Most helpful comment

Hi @ma0dubois,

Just to let you know, some performance issues have been detected on our side and have been solved with #11559. This is not live yet and should be available with PrestaShop 1.7.6.

About your question, the cache (re)generation is automatic when no translations are found in the catalog, as something has been potentially updated. We are also concerned by the performance on the front-office, and will see if that could be improved again by letting the catalog generation to the cache warmer.

All 7 comments

Hi @ma0dubois,

About your questions, this bug tracker GitHub is used to report issues and request new features only.
If you need help and support your request, you can ask on our Forum (https://www.prestashop.com/forums/)
Thanks for your understanding!
About your issue, we need more details to understand your issue

  • Version you started from: [e.g. 1.6.1.0]
  • Version you upgrade to: [e.g. 1.7.4.0]
  • Way of upgrade: Web?
  • Version of the 1-click upgrade module
  • Step concerned: [e.g upgrade DB]
  • debug mode report
  • PHP error logs
  • apache error log
  • javascript console log
  • screenshots

Thanks!

Hi @khouloudbelguith,

We performed a manual migration.
The 1-click upgrade module is not suitable for our case. But the problem is not the migration itself, today we successfully migrated our application in 1.7.4.3.
But as I told you, big performance problem was found on the front with the translations.

In the following method, why do you delete each cache file translation?

public function getTranslatorFromLocale($locale)
{
        [...]
        if (is_dir($cacheDir)) {
            $cache_file = Finder::create()
                ->files()
                ->in($cacheDir)
                ->depth('==0')
                ->name('*.'.$locale.'.*');
            (new Filesystem())->remove($cache_file);
        }
        [...]
}

This method, strongly impacts our dev environments (Windows 10).
Do you think it's possible to use the Symfony Message method for the front?

public function getTranslatorFromLocale($locale)
{
        $cacheDir = _PS_CACHE_DIR_.'translations';
        $translator = new Translator($locale, null, $cacheDir, false);

        // In case we have at least 1 translated message, we return the current translator.
        // If some translations are missing, clear cache
        if (count($translator->getCatalogue($locale)->all())) {
            $this->translator = $translator;
            return $translator;
        }
        [...]
}

If a developer Prestashop can inform us on the subject.
Thank you

Hi @ma0dubois,

Just to let you know, some performance issues have been detected on our side and have been solved with #11559. This is not live yet and should be available with PrestaShop 1.7.6.

About your question, the cache (re)generation is automatic when no translations are found in the catalog, as something has been potentially updated. We are also concerned by the performance on the front-office, and will see if that could be improved again by letting the catalog generation to the cache warmer.

Hi @ma0dubois,

Just to let you know, some performance issues have been detected on our side and have been solved with #11559. This is not live yet and should be available with PrestaShop 1.7.6.

About your question, the cache (re)generation is automatic when no translations are found in the catalog, as something has been potentially updated. We are also concerned by the performance on the front-office, and will see if that could be improved again by letting the catalog generation to the cache warmer.

Thank you very much for your answer !

Hi @ma0dubois,

So, can I close the issue?
Thanks!

Hi @ma0dubois,

So, can I close the issue?
Thanks!

Yes you can close :)

Hi @ma0dubois,

Thanks for your feedback.
I close the issue, feel free to open a new one when needed.
Thanks!

Was this page helpful?
0 / 5 - 0 ratings