Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324875 - [DataBinding] MapDelegatingValueObservableMap performance problems
Summary: [DataBinding] MapDelegatingValueObservableMap performance problems
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-09 13:27 EDT by przemyslaw.pelczar@araneo.pl CLA
Modified: 2021-11-12 17:35 EST (History)
1 user (show)

See Also:


Attachments
call tree from profiler (41.12 KB, image/png)
2010-09-09 13:30 EDT, przemyslaw.pelczar@araneo.pl CLA
no flags Details
call tree - details of MapEntry.getValue (37.51 KB, image/png)
2010-09-09 13:36 EDT, przemyslaw.pelczar@araneo.pl CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description przemyslaw.pelczar@araneo.pl CLA 2010-09-09 13:27:25 EDT
Build Identifier: 20100617-1415

MapDelegatingValueObservableMap uses IObservableMap.containsKey in MapEntry.getValue(), MapEntry.setValue() and put() methods. 

In most cases implementation of containsKey is AbstractMap (because AbstractObservableMap extends AbstractMap). This causes big performance problems, because AbstractMap.containsKey has linear complexity.

Invoking AbstractMap.containsKey should be avoided.

Happily MapEntry.getValue() can be changed to not use this method.
Now is:
public Object getValue() {
 getterCalled();
 if (!masterMap.containsKey(key))
   return null;
 Object masterValue = masterMap.get(key);
 return cache.get(masterValue);
}
Should be:
public Object getValue() {
 getterCalled();

 Object masterValue = masterMap.get(key);
 if (masterValue == null) {
  return null;
 } 
 return cache.get(masterValue);
}

Now adding 1000 elements to WritableList binded to TableViewer using ViewerSupport causes about 500 000 invocations of SetDelegatingValueObservableMap.EntrySet.next()


Reproducible: Always

Steps to Reproduce:
1. Bind TableViewer with few columns to WritableList using ViewerSupport.bind 
2. Try to add more that 1000 elements to WritableList.
Comment 1 przemyslaw.pelczar@araneo.pl CLA 2010-09-09 13:30:52 EDT
Created attachment 178536 [details]
call tree from profiler
Comment 2 przemyslaw.pelczar@araneo.pl CLA 2010-09-09 13:36:41 EDT
Created attachment 178537 [details]
call tree - details of MapEntry.getValue

You can see that in MapDelegatingValueObservableMap.MapEntry.getValue invoking DecoratingObservableMap.containsKey() takes 99% of time because it's delegated to AbstractMap.containsKey(). On the other hand DecoratingObservableMap.get() is fast because its delegated to HashMap.get().
Comment 3 Matthew Hall CLA 2010-09-13 22:02:52 EDT
Sounds like a better solution is to override containsKey to use the HashMap method like get() is doing--no?
Comment 4 przemyslaw.pelczar@araneo.pl CLA 2010-09-14 07:14:56 EDT
I think you are right.

Maybe SetDelegatingValueObservableMap and MapDelegatingValueObservableMap
should override containsKey and use DelegatingCache cache property in it.

I don't know details of implementation. 
But feel that case of null key in maps should be analysed to propose good solution.
Comment 5 Eclipse Webmaster CLA 2019-09-06 16:14:06 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 6 Eclipse Genie CLA 2021-11-12 17:35:12 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.