ViewBacking objects would always have layout properties attached to them even when unnecessary (In Everwing, about 80 views are using layout properties out of several thousand views).
I hypothesized that the way the ViewBackingExtension was written could stop the optimizer-compiler from properly optimizing a few methods (the updateGlobalTransform still was not down to the expected resource usage regarding its work load as mentioned in https://github.com/gameclosure/timestep/pull/123).
How
A LayoutViewBacking subclass of ViewBacking now replaces the ViewBackingExtension.
Only views that have a layout instantiate a style using the LayoutViewBacking constructor (Other views simply have a style of type ViewBacking). This LayoutViewBacking extension was rewritten to avoid using the setProperty API.
Also made sure that some class properties are initialized in the constructor to limit the number of hidden classes used by methods of the rendering pipeline.
Note: No refactoring is need in the code base of existing games but in order to achieve it a _setLayout method that would trigger when updating the layout on a view style was added to View. This method looks like an elaborate hack, I think that ideally we would need to figure out a different way to create layouts.
Results
Overall it looks like a minor performance improvement (~5%) and would not expect a huge FPS boost from this PR.
Engine tick
The ticking of the engine appears ~15% faster though:
Before
After
Chrome profile (macbook)
Before
After
Safari profile (iPhone 7)
Before
After
Resource usage of the updateGlobalTransform has been divided by more than 3 on both Chrome and Safari. It now seems that this method is properly optimized to the expected level.
Note: On safari iOS it appears that the profiler is not working entirely properly . Self time = total time and idle time is non-existent but seems to be hiding under the drawElements profile.
Under this assumption it seems that idle time increase by 4%, hinting at a 7% performance boost (from 56% non-idle time to 52%).
Why
ViewBacking
objects would always have layout properties attached to them even when unnecessary (In Everwing, about 80 views are using layout properties out of several thousand views).I hypothesized that the way the
ViewBackingExtension
was written could stop the optimizer-compiler from properly optimizing a few methods (theupdateGlobalTransform
still was not down to the expected resource usage regarding its work load as mentioned in https://github.com/gameclosure/timestep/pull/123).How
A
LayoutViewBacking
subclass ofViewBacking
now replaces theViewBackingExtension
. Only views that have a layout instantiate a style using theLayoutViewBacking
constructor (Other views simply have a style of typeViewBacking
). ThisLayoutViewBacking
extension was rewritten to avoid using thesetProperty
API.Also made sure that some class properties are initialized in the constructor to limit the number of hidden classes used by methods of the rendering pipeline.
Note: No refactoring is need in the code base of existing games but in order to achieve it a
_setLayout
method that would trigger when updating the layout on a view style was added toView
. This method looks like an elaborate hack, I think that ideally we would need to figure out a different way to create layouts.Results
Overall it looks like a minor performance improvement (~5%) and would not expect a huge FPS boost from this PR.
Engine tick
The ticking of the engine appears ~15% faster though: Before
After
Chrome profile (macbook)
Before
After
Safari profile (iPhone 7)
Before
After
Resource usage of the
updateGlobalTransform
has been divided by more than 3 on both Chrome and Safari. It now seems that this method is properly optimized to the expected level.Note: On safari iOS it appears that the profiler is not working entirely properly . Self time = total time and idle time is non-existent but seems to be hiding under the
drawElements
profile. Under this assumption it seems that idle time increase by 4%, hinting at a 7% performance boost (from 56% non-idle time to 52%).