Replies: 4 comments
-
Hi @the-ge The change on the str2url method introduced these issues, but already reported and "solved": |
Beta Was this translation helpful? Give feedback.
-
Oh, right. I apologize for not checking properly beforehand. It seems that the changes found their place in 8.1.3. Still, a marginal improvement - from 1.8...2seconds to less than 1.5 seconds for 5000 combinations - is brought by enveloping the string processing in a empty string checking condition, going from : 864 foreach ($ac as &$val) {
865 $val = str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::str2url(str_replace([',', '.'], '-', $val)));
866 } in ProductController, to: 864 foreach ($ac as &$val) {
865 if ($val !== '') {
866 $val = str_replace(Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), '_', Tools::str2url(str_replace([',', '.'], '-', $val)));
867 }
868 } On another totally unrelated matter, English is not my native language, thus not all its subtleties make it to me. Why did you quote |
Beta Was this translation helpful? Give feedback.
-
You don't need to apologize, just posted cause I remembered the issue with str2url, and as you can see all your quoted lines contain this method. And "solved" because you're right, passing empty strings to a function that doesn't check for them is a waste of resources and time. Can you create a PR? |
Beta Was this translation helpful? Give feedback.
-
Here you are: #36039. |
Beta Was this translation helpful? Give feedback.
-
The problem
Working on a store having products with thousands of variants, I arrived to the
assignAttributesCombinations()
method of ProductController, which took ~ 23 seconds to run.I found two optimizations that cut the time to less than 2 seconds.
While most of the stores do not have that amount of product variants, maybe these optimizations are still of interest ¯\_(ツ)_/¯
The solution
In the 8.1 branch, the code I'm talking about is:
First optimization (lines 891-893 below) - skipping the processing done in line 894 for empty strings - cut the time from 23 seconds to 13 seconds:
The second optimization - taking the class method calls/object creation out of the loop in lines 889-903 - cut the time to less than 2 seconds:
Alternatives
The second optimization could be done in a new method instead of an anonymous function and/or without calling the value by reference.
Additional context
The code above is from ProductController in the 8.1 branch. The site I'm working and testing on is based on 8.1.2.
Do you plan to work on this subject?
Beta Was this translation helpful? Give feedback.
All reactions