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.

+2


a source to share


3 answers


I think you need to add display fields to your profile and return them with the profile. Its fine to return the entire profile in a single inspector window, but if you have them in the overview view, you must return them to the original query.



+1


a source


Patrick, do you call Collections.binarySearch

at the Remote

facilities? You may have accidentally caused a huge amount of network traffic if this method is to query the rmi server for more information about objects.



+1


a source


(a) This has nothing to do with RMI.

(b) Faffing around with binarySearch () is just wasting time. Sort items first or last with Collections.sort (), or create your TreeModel in a default sorted collection.

0


a source







All Articles