Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » CalculatedValueCache Deadlock
CalculatedValueCache Deadlock [message #1744573] Wed, 28 September 2016 13:15 Go to next message
Chris Lingwood is currently offline Chris LingwoodFriend
Messages: 5
Registered: August 2014
Junior Member
I appear to be getting a deadlock from the calculated value cache which I'm using for thumbnails (with custom painter) in my table (if there is a better way please shout).

The calulcated value cache worker thread fires a layer event which propagates throug the layers ending with a Display.syncExec (because it started in a worker thread). So far so good.

Unfortunately the main thread is busy trying to aquire a lock from eventHelperLock so this never happens. The lock can't be aquired because the calculated value cache worker thread has it (it is named as the "first reader" in the ReentrantReadWriteLock's sync object.

Most of the time this code works fine but it will inevitably go wrong occasionally. Especially when scrolling or repainting from a sort or filter.

It looks to me like a bug in the calculated value cache but I could well have things configured non optimally. Any thoughts?

Thanks!

Edit: I should also mention this is nattable 1.5.0 and an eclipse neon rcp application.

Calculated value cache worker thread.
Thread [pool-8-thread-144] (Suspended)	
	waiting for: RunnableLock  (id=511)	
	Object.wait(long) line: not available [native method]	
	RunnableLock(Object).wait() line: 502 [local variables unavailable]	
	Synchronizer.syncExec(Runnable) line: 246	
	Display.syncExec(Runnable) line: 4813	
	NatTable$3.getClientArea() line: 335	
	GridLayer(CompositeLayer).getChildClientArea(int, int) line: 682	
	CompositeLayer.access$3(CompositeLayer, int, int) line: 679	
	CompositeLayer$1.getClientArea() line: 641	
	ViewportLayer.getClientAreaWidth() line: 1502	
	ViewportLayer.getColumnCount() line: 561	
	CellVisualChangeEvent.convertToLocal(ILayer) line: 63	
	ViewportLayer(AbstractLayer).handleLayerEvent(ILayerEvent) line: 260	
	ViewportLayer.handleLayerEvent(ILayerEvent) line: 1332	
	SelectionLayer(AbstractLayer).fireLayerEvent(ILayerEvent) line: 302	
	SelectionLayer(AbstractLayer).handleLayerEvent(ILayerEvent) line: 261	
	ColumnHideShowLayer(AbstractLayer).fireLayerEvent(ILayerEvent) line: 302	
	ColumnHideShowLayer(AbstractLayer).handleLayerEvent(ILayerEvent) line: 261	
	ColumnHideShowLayer(AbstractColumnHideShowLayer).handleLayerEvent(ILayerEvent) line: 50	
	ColumnHideShowLayer.handleLayerEvent(ILayerEvent) line: 66	
	ColumnReorderLayer(AbstractLayer).fireLayerEvent(ILayerEvent) line: 302	
	ColumnReorderLayer(AbstractLayer).handleLayerEvent(ILayerEvent) line: 261	
	ColumnReorderLayer.handleLayerEvent(ILayerEvent) line: 101	
	DataLayer(AbstractLayer).fireLayerEvent(ILayerEvent) line: 302	
	[b]CalculatedValueCache$1.run() line: 210[/b]
	ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1142	
	ThreadPoolExecutor$Worker.run() line: 617 [local variables unavailable]	
	Thread.run() line: 745 [local variables unavailable]	


Main thread:
Thread [main] (Suspended)	
	Unsafe.park(boolean, long) line: not available [native method]	
	LockSupport.park(Object) line: 175	
	ReentrantReadWriteLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterrupt() line: 836 [local variables unavailable]	
	ReentrantReadWriteLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(AbstractQueuedSynchronizer$Node, int) line: 870	
	ReentrantReadWriteLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int) line: 1199	
	ReentrantReadWriteLock$WriteLock.lock() line: 943 [local variables unavailable]	
	ViewportLayer(AbstractLayer).registerEventHandler(ILayerEventHandler<?>) line: 269	
	ViewportLayer.moveRowPositionIntoViewport(int) line: 976	
	ViewportLayer.moveCellPositionIntoViewport(int, int) line: 889	
	ViewportLayer.processSelection(CellSelectionEvent) line: 1443	
	ViewportLayer.handleLayerEvent(ILayerEvent) line: 1325	
	SelectionLayer(AbstractLayer).fireLayerEvent(ILayerEvent) line: 302	
	SelectionLayer.fireCellSelectionEvent(int, int, boolean, boolean, boolean) line: 592	
	SelectCellCommandHandler.doCommand(ILayer, SelectCellCommand) line: 42	
	SelectCellCommandHandler.doCommand(ILayer, ILayerCommand) line: 1	
	SelectionLayer(AbstractLayer).doCommand(ILayerCommand) line: 186	
	SelectionLayer(AbstractIndexLayerTransform).doCommand(ILayerCommand) line: 105	
	SelectionLayer.doCommand(ILayerCommand) line: 579	
	ViewportLayer(AbstractLayerTransform).doCommand(ILayerCommand) line: 106	
	ViewportLayer.doCommand(ILayerCommand) line: 1086	
	BodyLayerStack(AbstractLayerTransform).doCommand(ILayerCommand) line: 106	
	GridLayer.doCommandOnChildLayer(ILayerCommand, ILayer) line: 113	
	GridLayer.doCommandOnChildLayers(ILayerCommand) line: 99	
	GridLayer(CompositeLayer).doCommand(ILayerCommand) line: 136	
	GridLayer.doCommand(ILayerCommand) line: 187	
	NatTable.doCommand(ILayerCommand) line: 812	
	SelectCellAction.run(NatTable, MouseEvent) line: 25	
	ConfigurableModeEventHandler.mouseDown(MouseEvent) line: 45	
	ModeSupport.mouseDown(MouseEvent) line: 108	
	TypedListener.handleEvent(Event) line: 193	
	EventTable.sendEvent(Event) line: 84	
	Display.sendEvent(EventTable, Event) line: 4410	
	NatTable(Widget).sendEvent(Event) line: 1079	
	Display.runDeferredEvents() line: 4228	
	Display.readAndDispatch() line: 3816	
	PartRenderingEngine$4.run() line: 1121	
	Realm.runWithDefault(Realm, Runnable) line: 336	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1022	
	E4Workbench.createAndRunUI(MApplicationElement) line: 150	
	E4Application.start(IApplicationContext) line: 161	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 134	
	EclipseAppLauncher.start(Object) line: 104	
	EclipseStarter.run(Object) line: 388	
	EclipseStarter.run(String[], Runnable) line: 243	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 498	
	Main.invokeFramework(String[], URL[]) line: 673	
	Main.basicRun(String[]) line: 610	
	Main.run(String[]) line: 1519	
	Main.main(String[]) line: 1492	


[Updated on: Wed, 28 September 2016 13:24]

Report message to a moderator

Re: CalculatedValueCache Deadlock [message #1744576 is a reply to message #1744573] Wed, 28 September 2016 14:01 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
You are using the CalculatedValueCache for thumbnails? I would have never come to that idea. Why? Is the calculation of the thumbnail values so expensive?

It doesn't look to me like an issue in the CalculatedValueCache. That class does not aquire a lock. It more looks like an issue related to internal event handling. Probably AbstractLayer#handleLayerEvent and AbstractLayer#registerEventHandler cause the deadlock.

Need to investigate on this. Please create a ticket.
Re: CalculatedValueCache Deadlock [message #1744587 is a reply to message #1744576] Wed, 28 September 2016 15:47 Go to previous messageGo to next message
Chris Lingwood is currently offline Chris LingwoodFriend
Messages: 5
Registered: August 2014
Junior Member
Thanks for the quick reply.

Will do. I had a look through the source and it does aquire a readlock a few times as it propagates through but I couldn't see why it was claiming a write lock as well (that said some of the linked sources aren't working in my environment for some reason). The sync object did point at that thread though so it must have somewhere along the line.

I ended up using the calulcated value cache to allow faster painting. It seemed to give me lazy loading and caching "for free". I've got a table wtih 11k rows probably half of which have thumbnails. A full repaint without a cache or lazy loading (or for new items with just a cache) would need the loading, scaling and painting of 20odd thumbnails. The value cache just stores the ImageData so there is some overhead there but I'd run out of handles otherwise. I get a bit of flicker at the best of times.

Honestly I thought I'd got the idea from one of your posts but I can't find it anywhere. How would you have gone about it?

[Updated on: Wed, 28 September 2016 16:00]

Report message to a moderator

Re: CalculatedValueCache Deadlock [message #1744589 is a reply to message #1744587] Wed, 28 September 2016 15:59 Go to previous messageGo to next message
Chris Lingwood is currently offline Chris LingwoodFriend
Messages: 5
Registered: August 2014
Junior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=502469

Thinking about it you are right that its not a CalculatedValueCache issue as such. Its threadpool does show it up though, if it was in the main thread the syncExec wouldn't lock.
Re: CalculatedValueCache Deadlock [message #1744611 is a reply to message #1744589] Wed, 28 September 2016 20:19 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I pushed a patch to Gerrit

https://git.eclipse.org/r/#/c/82117/

Is it possible for you to test this locally?
Re: CalculatedValueCache Deadlock [message #1744738 is a reply to message #1744611] Thu, 29 September 2016 18:47 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I merged my patch now so people are able to test easily with the latest SNAPSHOT build.

Regarding you question, when resources are involved I always use JFaceResources. We utilize it in the GUIHelper class.
Previous Topic:NatTable Drawing FPS / Performance vs SWT table
Next Topic:GroupBy - how to refresh groups after data changed?
Goto Forum:
  


Current Time: Thu Apr 25 11:13:54 GMT 2024

Powered by FUDForum. Page generated in 0.03267 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top