Opened 8 years ago
Closed 8 years ago
#16660 closed enhancement (fixed)
[patch][ccla] Reduce call stack in _ContentPaneResizeMixin#_layoutChildren
Reported by: | Kenneth G. Franqueiro | Owned by: | bill |
---|---|---|---|
Priority: | undecided | Milestone: | 1.9 |
Component: | Dijit | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description (last modified by )
A customer identified a potential improvement to the _layoutChild
method of _ContentPaneResizeMixin
which has potential to significantly reduce the depth of call stacks (which can reduce memory consumption particularly in old IE).
The change involves changing from using array.forEach
to using a straight for
loop. Because the code in question is within _layoutChildren
which is called by resize
, this has potential to reduce the number of function calls not only on an individual ContentPane?, but also any nested ContentPanes? underneath.
Attaching a patch (under SitePen? CCLA). This patch was created from the 1.7 branch (since the customer is on 1.7), but will also cleanly apply to 1.8 and trunk.
Attachments (1)
Change History (6)
Changed 8 years ago by
Attachment: | layoutchildren.diff added |
---|
comment:1 Changed 8 years ago by
comment:2 Changed 8 years ago by
Yeah, your loop would probably work too.
The idea is that it no longer has to call forEach
, nor would forEach
perform additional calls to a callback, so it should be 2 fewer levels of recursion for each recursive level of ContentPane resizes.
Admittedly I was not able to see a noticeable performance difference myself (I tried, with a drastically unrealistic amount of nesting), and it's hard to really nail memory consumption since ostensibly memory would bounce back to normal the moment the resize operation completes.
comment:3 Changed 8 years ago by
Description: | modified (diff) |
---|---|
Summary: | [patch][ccla] Reduce recursion in _ContentPaneResizeMixin#_layoutChildren → [patch][ccla] Reduce call stack in _ContentPaneResizeMixin#_layoutChildren |
After talking with Bill on IRC, I'm realizing that what I mean isn't technically reduced recursion, but reduced call stack depth. Changing title to hopefully clarify.
comment:4 Changed 8 years ago by
Milestone: | tbd → 1.9 |
---|---|
Status: | new → assigned |
Type: | defect → enhancement |
OK, I'll switch it to a native loop in case it makes a difference.
My guess is that
would be even faster.
It's hard to believe either change is significant though, nor would I say that the change reduces recursion. But if it actually does reduce memory usage in a measurable way we should do it.