Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » GlazedListsEventLayer: multi-threading issue
GlazedListsEventLayer: multi-threading issue [message #1101454] Wed, 04 September 2013 09:27 Go to next message
Steve Kramer is currently offline Steve Kramer
Messages: 8
Registered: January 2013
Junior Member
Hi

I've come across an issue with NatTable 1.0.1 when the underlying EventList of a NatTable is updated asynchronously via a separate thread. Effectively, the NatTable doesn't seem to refresh reliably when adding multiple elements to the underlying eventList using the addAll() method. Adding a few hundred rows seems to work fine in my environment (OSX 10.7) but adding half a million rows at a time fails and the table appears empty after the update.

Looking into the details of the GlazedListsEventLayer.fireEventFromSWTDisplayThread() method I noticed that it doesn't lock the underlying eventList before firing the event to the layer stack. This allows for a race condition as the event is allowed to propagate up the layer stack before the appropriate eventList is being unlocked by the updating thread.

What is the specific reason for not locking the eventList before firing the event to the layer stack ?

The issue I described above can be reliably reproduced with a slightly modified version of the _200_Group_by example from the NatTable 1.0.1 distribution. I can email the file to anybody interested in more details. The same issue revealed another bug in the ViewportEventHandler.handleLayerEvent() method where the case handing vertical structure changes is using scrollableLayer.getColumnCount() instead of scollableLayer.getRowCount() on line 76.

Best
Steve

Re: GlazedListsEventLayer: multi-threading issue [message #1101478 is a reply to message #1101454] Wed, 04 September 2013 10:07 Go to previous messageGo to next message
Edwin Park is currently offline Edwin Park
Messages: 123
Registered: July 2009
Senior Member
I remember we had a similar situation on an application we worked on many years ago with NatTable. The problem was if you sent massive numbers of updates, you'd wind up generating massive numbers of events, which would lock up the table and do all sorts of unnecessary work. Our solution was to manually turn off updates, do the massive batch insert, and then turn on updates and refresh the table again. You may want to do something similar.

Edwin
Re: GlazedListsEventLayer: multi-threading issue [message #1101700 is a reply to message #1101478] Wed, 04 September 2013 17:01 Go to previous message
Steve Kramer is currently offline Steve Kramer
Messages: 8
Registered: January 2013
Junior Member
Edwin

Thanks for your suggestion but I'm wondering how such a solution would look like in details. I'm already batching the update to the underlying list into a single call to the eventList.addAll() method. In other words, I'm adding a few hundred rows to an empty table in one single statement. Sometimes it works and sometimes it doesn't depending on the thread scheduling of the machine. Another complication would be to determine the number of records that can be directly inserted into the list as opposed to be inserted via the "bulk update mechanism". Such a limit also seems to be dependent on the machine speed and OS. The simple example inserting as few as 500 records at a time is failing on a dual core laptop but works fine on an eight core desktop machine.

I guess one reliable solution would entail to force *all* updates to the eventList to be performed by the UI thread and effectively single thread the updating of the eventList. If that's the case then I don't quite see the need for the GlazedListsEventLayer. Maybe I'm missing something from an architectural point that you can shed some light on.

Thanks
Steve
Previous Topic:Highlight filtered text
Next Topic:Right click to select cell
Goto Forum:
  


Current Time: Mon Oct 07 21:10:14 EDT 2013

Powered by FUDForum. Page generated in 0.01550 seconds