Bug 562127 - ViewCSSImpl getComputedStyle results in too many calls to getParentNode
Summary: ViewCSSImpl getComputedStyle results in too many calls to getParentNode
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.16   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 4.16 M3   Edit
Assignee: Mike Marchand CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks: 560449
  Show dependency tree
 
Reported: 2020-04-14 16:47 EDT by Mike Marchand CLA
Modified: 2020-04-17 14:30 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Marchand CLA 2020-04-14 16:47:21 EDT
This is related to bug 550662 but it is about a different optimization opportunity.

I was able to identify a problem in getComputedStyle and the ExtendedSelectors.  The problem is that they are calling getParentNode() in each match() call, in my case, one click which populates a view for the first time can cause 350000+ calls to match().  I was able to come up with a solution that is API safe (With a default API that would fall back to historical behavior).  The time with my solution, in my scenario calling getComputedStyle exactly 869 times is reduced from 2.507s to 0.961s.
 
Basically my solution is to avoid calling getParentNode() in selector code by computing an array of parent nodes in getParentNode, and passing that, plus an index to match.

I will provide a Gerrit.
Comment 1 Eclipse Genie CLA 2020-04-14 17:24:56 EDT
New Gerrit change created: https://git.eclipse.org/r/160947
Comment 2 Karsten Thoms CLA 2020-04-15 18:45:47 EDT
Good catch, Mike. The patch looks promising.
Comment 4 Alex Blewitt CLA 2020-04-16 04:58:34 EDT
Nice work!