You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve performance of DataObject magic calls and addData()
The magic calls from the DataObject are being called over a 100k when there is no block_cache available and depending on the page often thousands of times when all block_cache is available.
The small change for addData() is just included because its a tiny optimization and prevents a bug from happening. When a $value is an array the original call to setData would override the internal $_data array, this is not expected behavior and just setting it directly to $_data is faster anyway.
The other change is in the __call magic method and the _underscore function and the change is quite radical.
Since this method can be called so often, we want to prevent further function calls if possible. Functional calls are normally not that expensive, but will become more expensive if you use this extensively (thousands of even hundred of thousands extra calls):
These are my own benchmarks based on a local environment with opcache and with PROD mode.
HOMEPAGE transaction
All cache enabled except for FPC (__call is called 975 times): 4.318307ms -> 1.469747ms
All cache enabled except for FPC + Block_html (__call is called 100379 times): 385.36412ms -> 88.412914ms
PLP transaction:
All cache enabled except for FPC (__call is called 4628 times): 19.625463ms -> 5.754514ms
All cache enabled except for FPC + Block_html (__call is called 112591 times): 404.84066ms -> 99.390374ms
Now this PR also skips some checks. It assumes if a $method call start with 'g' it will be for 'get' for example, this is done in my PR to get the most optimal performance result but might not be preferred. I also removed an index check with $args[1] for the setter since it isn't used anywhere, but might also be something we would want to change.
0 commit comments