Increase in latency / load time
-
With the update from 5.2 to 5.3 we see a massive increase in loading times. Our website loaded within about 300-400ms (uncached), which is raised to 600-800ms since the update. We already reverted, and the second we did, loading times decreased to normal again. Any ideas what new feature in 5.3 could cause this behaviour?
-
Hi @comotive ,
hope you’re fine. Sorry for the issue you’re facing and thanks for the feedbacks it’s help. We planned a release of the 5.4 next week, but you can test the beta version here and tell me if you still see your massive increase : https://we.tl/t-DpGgB8gMRg?
On my side i’ll compare the 2 versions (5.2/5.3) code change on the repo to check what update can explain the increase your faces
regardsThanks for the immediate response. I’il have a look into the new version and also do comparisons with claude, because maybe it’s specific to our setup (it’s quite a massive high traffic shop utilizing galera/mariadb clusterand redis object cache). Thanks and I’il keep you posted!
thank for the reply, keep me in touch if you need some help, i’ll keep the thread open for the moment.
Regards 😉An update to 5.4 didn’t help. Claude analyzed as follows:
—-Performance culprit: matomo/device-detector
The main suspect is the new DeviceDetector library (Server.php:58-60). In v5.3, Weglot
replaced their bot detection with matomo/device-detector — a heavy library that:- Parses the full User-Agent string against thousands of regex patterns from large
YAML files (browsers, bots, devices, OS — ~70k lines of regexes added in this commit) - Runs on every single page request — Server::detectBot() is called during the
translation flow to determine if the visitor is a bot - Has no caching — each request re-instantiates new DeviceDetector($userAgent) and
calls $dd->parse(), which runs through all those regexes fresh every time Previously Weglot likely had a simple string-match bot check. Now it loads and
evaluates a full device detection library.
Other changes (less likely culprits)
- New preserve_words feature with regex processing (but only runs if
weglot_preserve_words_enabled filter returns true — off by default) - New Iubenda third-party integration (only loads if Iubenda plugin is active)
- New get_default_regex_checkers() for data-et-multi-view attributes (Divi builder)
—
I’ve mitigated by injecting a class loader like this
spl_autoload_register(function ($class) {
if ($class === ‘DeviceDetector\\DeviceDetector’) {
require_once __DIR__ . ‘/src/customer_name/Weglot/CachedDeviceDetector.php’;
return true;
}
return false;
}, false, true);
The CachedDeviceDetector then roughly does the same as the original class. Doing this actually results in -400ms, so claude is most likely correct 🙂 I’il keep that in place until this might be solved (by object caching?) within the plugin.-
This reply was modified 2 months, 1 week ago by
comotive. Reason: made it more clear that our own CachedDeviceDetector does kinda the same, so code depending on it still works
Thanks for the feedback 😉
Indeed, we had a manual user agent list and we switched to a library to have an up-to-date and maintained list, and I haven’t measured the impact. I’ll open the issue on my end to add caching or see if a lighter library is available. It will probably be released in 5.5 and not 5.4.
RegardsHi @comotive ,
are you able to test this version of the plugin : https://we.tl/t-7FAugGBLPH
i’ve just make a POC adding devicedetectorcaching feature.
Let me know if it’s better
RegardsI can’t edit my previous message, please test this version : https://we.tl/t-7palGPJrMJ
RegardsHi @comotive ,
are you able to test the version i provide ? Tell me if you need me to resend it.
Regards@glx77 I’m sorry I wasn’t able do download it before it already expired. I’il gladly test it today if you could re-upload it.
no worries, take your tme, you can add the version including staticCache here : https://we.tl/t-BKvgakKjdb
Regards - Parses the full User-Agent string against thousands of regex patterns from large
You must be logged in to reply to this topic.