Massive performance regression since commit fbd332d
#734
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Report
The recent move to "OOP" patterns and code structures has heavily impacted performance as can be seen when running benchmarks:
TAG [1.8.0]
Stack with flex: median: 0.027000 ms, stddev: 0.005840 ms
Align stretch in undefined axis: median: 0.027000 ms, stddev: 0.005836 ms
Nested flex: median: 0.436000 ms, stddev: 0.067741 ms
Huge nested layout: median: 36.938000 ms, stddev: 2.847124 ms
COMMIT [
fbd332d
]Stack with flex: median: 0.042000 ms, stddev: 0.007671 ms
Align stretch in undefined axis: median: 0.036000 ms, stddev: 0.009329 ms
Nested flex: median: 0.748000 ms, stddev: 0.108319 ms
Huge nested layout: median: 50.196000 ms, stddev: 3.076368 ms
TAG [1.7.0]
Stack with flex: median: 0.010000 ms, stddev: 0.006567 ms
Align stretch in undefined axis: median: 0.012000 ms, stddev: 0.002526 ms
Nested flex: median: 0.152000 ms, stddev: 0.038512 ms
Huge nested layout: median: 12.710000 ms, stddev: 1.497397 ms
As far as I understand mostly due to unnecessary copies all over the place.
I'm not sure if this is a known issue, but I suggest taking a look at it before it becomes too hard to optimize/refactor.
any update?
Thanks for the report! We will look into this!
@emilsjolander am I right that this was corrected here
cda328fa7e
?@koxen I think so but would be good to confirm
@emilsjolander that would be great, would you mind bumping react-native to a beta version after you're done? :)
@emilsjolander @koxen
I have been tracking changes and have already profiled this and no, it didn't solve the issue.
Stack with flex: median: 0.033000 ms, stddev: 0.008888 ms
Align stretch in undefined axis: median: 0.032000 ms, stddev: 0.008994 ms
Nested flex: median: 0.561000 ms, stddev: 0.120899 ms
Huge nested layout: median: 39.258000 ms, stddev: 2.278808 ms
There are multiple places in the code where the YGLayout and/or YGStyle are being copied instead of referenced...
eg.
............ Why??
Should just be the following:
There are many more such places in the code,
I believe this is not a quick fix, this require a more careful review of the current refactoring and potential risks involved.
Note that I've tried and cleaned up most of the YGStyle and YGLayout copies and still did not change that much, just a few percents which makes me think that there may be something ugly going on somewhere.
@Edensan yes, those macros could be adapted, but they aren't heavily used in the benchmark tool.
After having a look throughout the code, my assumption about the performance penality is that the implementation of the
YGNode
getters aren't decleared directly in theYGNode
header. This could lead to the behaviour that these calls aren't inlined correctly (as it only sees theYGNode.h
definition and not the concrete implementation insideYoga.cpp
).I haven't verified that this is the root cause here, but I experienced similar things in other projects.
@woehrl01 Got it.
Since you mentioned it, I suppose refreshing the benchmarks might also be a good idea.
I am seeing noticable performance improvement in my RN app(FlatList, items using lots of flexboxes) after upgrading to version with
cda328fa7e
..so it seems related. I would appreciate further pass-by-reference fixes like @Edensan pointed out :)
EDIT: might have been a false positive, looks like changes from master didn't land in 0.55.1 version tag :/
Is there someone working on this issue at the moment? Would be nice to keep us updated.
Looks like still not fixed.
From the benchmark, Yoga 1.6.0 is two times faster than 1.14.0.
https://gist.github.com/gengjiawen/141051afa3aa2d6745e86be69c60c2fb