Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

IndexedContainerProperty.hashCode() CPU Load

Alexey Brodovshuk
1 decade ago Jan 13, 2012 9:40am
Henri Sara
1 decade ago Jan 13, 2012 9:58am

Alexey Brodovshuk: We have experienced a large CPU load impact by IndexedContainerProperty.hashCode() in our application.
It's called each time we add new item to the container keeping CPU busy. Is that a normal behavior? If yes, is there any way to optimize it?
Items are added to TreeTable.

If this is not just an artifact from your profiler settings:

IndexedContainerProperty.hashCode() does almost nothing itself - it only calls itemId.hashCode() and propertyId.hashCode(). I suspect that one of these types has an expensive hashCode() method, and it shows up in your profiler as time in ICP.hashCode() as it gets inlined here by the JVM.

Check also the number of calls and where they come from - is one caller dominating the number of calls?

Finally: If adding a lot of items at once, it might make sense to do it before attaching the container to the component, as far fewer notifications about changes need to be processed by the component in that case. Using some container designed to be hierarchical instead of an IndexedContainer that gets wrapped in a ContainerHierarchicalWrapper or a HierarchicalContainerOrderedWrapper might also help.

Alexey Brodovshuk
1 decade ago Jan 27, 2012 3:15am