DESCRIPTION

tmf: Fix time graph combo freezing when expanding parent of many items

When expanding an item in the time graph combo, the expanded state of
every child item needs to be synched between the tree and the time
graph, due to inconsistent behavior between platforms. When the parent
has hundreds of child items, this can take several seconds due to the
inefficient searching for the item corresponding to a time graph entry
in both the tree and the time graph, for getting and setting the
expanded state.

For the tree, instead of gettting the expanded state of each item from
the tree viewer using the model element, the list of expanded elements
is retrieved once and the expanded state can be deduced by the presence
or absence of a model element in this list. Furthermore the synching of
expanded state is only performed for child items that have children
themselves.

For the time graph, the item model is changed to use a map from time
graph entry to time graph item, which greatly reduced the time necessary
to find the item corresponding to an entry. The expanded item index is
also stored directly in the item which avoids the need to iterate to
find an expanded time graph entry's index.

Change-Id: Icefc393be8a5e2ee1a98b98a2c6b126da7490035
Signed-off-by: Luciana Barry xxx@xxx.xxx


COMMENTS

author: Luciana Barry
date: 2014-03-24 17:42:12.000000000

Uploaded patch set 1.

-------------------------------------
author: Brenden Conley
date: 2014-03-24 17:42:17.000000000

Patch Set 1:

Build Started https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/6079/

-------------------------------------
author: Brenden Conley
date: 2014-03-24 18:37:11.000000000

Patch Set 1: Verified+1

Build Successful 

https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/6079/ : SUCCESS

-------------------------------------
author: Braxton Mccarthy
date: 2014-03-24 18:58:18.000000000

Patch Set 1: Code-Review-1

(5 comments)

Line:413, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java -> Doning .contains() on a List is slow. You have to check every element one by one. aka O of something ;)

Since we're creating a new collection anyway, I tested by instead doing:
  Set<Object> expandedElements = new HashSet<>(Arrays.asList(fTreeViewer.getExpandedElements()));

It seems to be a little bit faster, measuring by putting System.nanotime() around this snippet, opening the "init" subtree of the test trace "kernel", I get 977,063.9 ns vs 1,515,863.7 ns (averaged over 10 tests).

Line:447, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java -> same here

Line:2401, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java -> could be final

Also, why a LinkedHashMap instead of a just HashMap? AFAICS, nothing iterates on the map, only .get() is used.

Line:2414, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java -> should have public modifier, for consistency.

Line:2543, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java -> could be final (so could "fName" and "fLevel")

-------------------------------------
author: Luciana Barry
date: 2014-03-24 20:11:57.000000000

Patch Set 1:

(2 comments)

Line:413, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java -> For 1,500 children, searching the hash set is a few times faster than using the list, and creating the hash set from the list does not have a significant cost, so it's a good tradeoff. But just a single call to getExpandedElements is about 30 times slower than the whole for loop, so this improvement is not really noticeable. Maybe with even more children...

Line:2430, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java -> Here is why we use a LinkedHashMap, to preserve the order in fItems.

-------------------------------------
author: Braxton Mccarthy
date: 2014-03-26 20:31:28.000000000

Patch Set 1:

(1 comment)

Line:2430, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java -> gotcha, I musta missed that!

-------------------------------------
author: Gerrit Code Review
date: 2014-03-27 14:15:05.000000000

The change could not be merged due to a path conflict.

Please rebase the change locally and upload the rebased commit for review.

-------------------------------------
