Bug 27073 - [Key Bindings] WWinKeyBindingService allocates ca. 7-8K of objects on each selection change in the workbench
Summary: [Key Bindings] WWinKeyBindingService allocates ca. 7-8K of objects on each se...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Chris McLaren CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2002-11-25 05:49 EST by Adam Kiezun CLA
Modified: 2002-12-18 14:41 EST (History)
0 users

See Also:


Attachments
allocation trace (4.69 KB, text/plain)
2002-11-25 05:50 EST, Adam Kiezun CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2002-11-25 05:49:26 EST
it calls isChildOf which in turn equals on lists - and that's expensive because 
it allocates a lot of iterator objects
attached is the allocation trace of java.util.AbstractList$ListItr after a 
single click in the workbench
Comment 1 Adam Kiezun CLA 2002-11-25 05:50:48 EST
Created attachment 2503 [details]
allocation trace
Comment 2 Adam Kiezun CLA 2002-11-25 06:01:17 EST
actually i think now that isChildOf is the culprit
it should be optimized for memory consumption - it's called very often
its code now:
public boolean isChildOf(KeySequence keySequence) {
	return keyStrokes.size() > keySequence.keyStrokes.size() &&
			keyStrokes.subList(0, keySequence.keyStrokes.size
()).equals(keySequence.keyStrokes);
}

this allocates new objects in subList() and in equals()
little recoding here will save a lot of garbage objects
Comment 3 Adam Kiezun CLA 2002-11-25 06:34:50 EST
another one is:
org.eclipse.ui.internal.actions.keybindings.Path.equalsOrIsChildOf
but it's called less often so it's less of a problem
Comment 4 Chris McLaren CLA 2002-11-25 14:28:48 EST
this definitely will be recoded. as well, i think there are a few calls in 
there (compare/equals) that compare lists by instantiating iterators first 
instead of for(;;) over them. this is a cause of unnecessary object creation as 
well.
Comment 5 Adam Kiezun CLA 2002-11-26 05:47:38 EST
yes, this class is used so often that it should really be tuned
the methos isChildOf is called an amazing number of times - any speedup there 
will help. 
eliminating the combination of sublist/equals and replacing with a simple 
iteration over elements would be a good start
Comment 6 Chris McLaren CLA 2002-12-02 13:01:26 EST
fixed. all compare, equals, isChildOf, and equalsOrIsChildOf methods have been 
optimized. No new objects should be allocated during these methods. Execution 
time should further improve due to minor algorithm changes as well.