-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very slow handling of SWT messages when millions of messages queued #74
Comments
Good finding! My sense is that org.eclipse.pde.internal.ui.editor.context.InputContextManager.resourceChanged(IResourceChangeEvent) should just build sets of added and removed resources and then do a single asyncExec in which it calls org.eclipse.pde.internal.ui.editor.context.InputContextManager.structureChanged(IFile, boolean) for each of those added/removed things. Then likely all the other methods will not be a significant performance concern anymore. |
PR request are welcome to replace the sync blocks, I assume that would benefit all parts of SWT. |
Most parts of SWT don't use any sync blocks, because SWT is single threaded. There are only few that contact with the "outer" world :-) |
Of course improvements are always welcome. :-) But no amount of improvement will make doing asyncExec per changed resource when processing a resource delta as reasonable design! :-P That's definitely just bad design and should be fixed. @jukzi Are you planning on fixing the "too many asyncExecs" problem?" |
Of course but this discovery is still good as it may speed up SWT in general. |
Not at the moment. I submitted an Issue on PDE for that so that hopefully PDE team could take a look. I will take a short look if i find a quick improvement for SWT meanwhile (my build is still running dequeuing the events after hours 😒 ). |
I have a fix but should I hold off? I recall there is a merge that should happen soon. I'll paste the changes in org.eclipse.pde.internal.ui.editor.context.InputContextManager.resourceChanged(IResourceChangeEvent) here so I don't loose them:
|
Sorry, I see the merge already happened! |
@merks i propose you create a PDE PR for eclipse-pde/eclipse.pde#53 |
PDE merge is still pending but please do not hold of any commits to PDE, we plan to merge pde build into pde next Monday and will be able to handle any work, so do not worry. |
Synchronizer.messages grew with constant size leading to O(n^2) performance for n messages. Also the costly "synchronized" can be avoided by using java.util.concurrent DataStructures. The message queue size (which is not O(1) for java.util.concurrent) is not needed since only checks for isEmpty() are used.
There is only 1 display - no need to search in an array of 4 displays during Display.findDisplay() It's a minor optimization for Display.findDisplay (). The greatest bottle neck is still the "synchronized" statement.
During eclipse-pde/eclipse.pde#53 is see terrible hotspots in
while the amount of messages in org.eclipse.swt.widgets.Synchronizer.addLast(RunnableLock) was > 1million.
All those functions show "synchronized" blocks, which could be probably avoided with the usage of appropriate classes of java.util.concurrent.
Sampling of SWT Thread:
And asyncExec() seen in a sampling of a background thread:
The text was updated successfully, but these errors were encountered: