Poor performance using RMI proxy with Swing components
I'm having big performance issues when adding RMI proxy references to a Java Swing JList component.
I am fetching a list of users Profile
with RMI from the server. The extraction itself only takes a second or so, so this is acceptable in the circumstances. However, when I try to add these proxies to JList
, using custom ListModel
and CellRenderer
, it takes 30 to 60 seconds to add about 180 objects. Since this is a list of usernames, he prefers to present them in alphabetical order.
The biggest performance hit is sorting items as they are added to the ListModel. Since the list will always be sorted, I decided to use the inline Collections.binarySearch()
to find the correct position for the next item to add, and the comparator uses two methods that are defined by the interface Profile
, namely getFirstName()
and getLastName()
.
Is there a way to speed up this process, or am I just implementing it incorrectly? Or is it a "feature" of RMI? I would love to be able to cache some remote object data locally to minimize calls to remote methods.
Update and possible solution: I created local classes that implement remote interfaces and contain a reference to remote objects. The speed boost is noticeable and now it works without visibility (at least so far). Hope this works the same for the other interfaces we use in our application. Thanks for the input, which I think helped to help me out.
a source to share