© 2004 ibm corporation | boston ma, april 19, 2004 john arthorne, eclipse platform core team the...
TRANSCRIPT
![Page 1: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/1.jpg)
© 2004 IBM Corporation | Boston MA, April 19, 2004
John Arthorne, Eclipse Platform Core Team
The Road to Responsiveness in Eclipse 3.0
![Page 2: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/2.jpg)
2 The road to responsiveness | © 2004 IBM Corporation
The road to responsiveness
Step 0 - If you make no changes, you will be ok (even slightly better)
Step 1 - Revisit locks to reduce contention with background jobs
Step 2 – Move long read only operations to background
Step 3 – Move long writing operations to background
![Page 3: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/3.jpg)
3 The road to responsiveness | © 2004 IBM Corporation
Step 0 – what if I do nothing?
Backwards compatibility: no worse than Eclipse 2.1
Blockage will always be reported to the user
The UI is kept alive (painting) at all costs
Cancelation is now always possible (even during deadlock)
Lack of responsiveness in one component can kill responsiveness gains in other components
![Page 4: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/4.jpg)
4 The road to responsiveness | © 2004 IBM Corporation
Step 1 - Revisit locks to reduce contention
ISchedulingRule: generic hierarchical locks A given scheduling rule can only be “owned” by one thread at a time
No two threads can own rules that conflict with each other
Implemented by clients – every plug-in can define their own rules
Rules can be nested to form rule hierarchies
ILock: re-entrant lock, like Java object monitors, except: Aware of syncExec: carries over to UI thread
Deadlock reporting and recovery
![Page 5: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/5.jpg)
5 The road to responsiveness | © 2004 IBM Corporation
Step 1 – Reducing contention (continued)
IWorkspace.run was used for both batching and locking
This has been decoupled: new IWorkspace.run with scheduling rule, WorkspaceJob subclass to obtain batching inside a job
Can now use scheduling rules to lock selected resources
IResource implements ISchedulingRule
![Page 6: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/6.jpg)
6 The road to responsiveness | © 2004 IBM Corporation
Step 2 – Move read-only operations to background
Less risk in moving read-only operations into background
Can be done with little or no contention
Watch for assumptions about UI thread and thread safety
Examples: searching, indexing, decoration, repository view
We have been doing this all along, but difficulties arise Hard to coordinate access to resources, CPU
Background processes that don’t know about each other are prone to deadlock
![Page 7: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/7.jpg)
7 The road to responsiveness | © 2004 IBM Corporation
Step 2 – Moving to the background (continued)
Job API: org.eclipse.core.runtime.jobs
Job: a unit of work scheduled to run asynchronously
Why not just java.lang.Thread? Lighter weight: uses a shared thread pool
Support for progress feedback and cancellation
Priorities and scheduling rules
Richer scheduling: run now, run later, run repeatedly
Job listeners can find out when jobs start, finish
![Page 8: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/8.jpg)
8 The road to responsiveness | © 2004 IBM Corporation
Step 3 – Move writing operations to background
Identify the big win operations – what common tasks will the user want to be able to perform in the background?
Trade-off is added complexity of code versus important responsiveness gains
Need to be aware of concurrency requirements of code you’re calling: locks acquired, etc
Be aware of deadlock risks and know avoidance strategies
![Page 9: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/9.jpg)
9 The road to responsiveness | © 2004 IBM Corporation
Step 3 (continued)
Avoid hold and wait: ISchedulingRule: allows jobs to specify requirements before they even
start (two phase locking).
Impossible to hold a rule and be waiting for a rule
Avoid holding locks while client code is called
Avoid syncExec and use asyncExec where possible
Avoid circular wait Always acquire locks in a consistent order
Preemption: If all else fails, preempt the thread that introduced deadlock and report
error in log. This happens for free with ILock and ISchedulingRule
![Page 10: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/10.jpg)
10 The road to responsiveness | © 2004 IBM Corporation
UI presentation of jobs
Generic job feedback Status line animation
Progress view User initiated jobs need strong feedback (out of box)
User wants to feel in control
When did it start/finish?
What are the results? View-specific jobs
Tell the user if the view is busy or invalid (half-busy cursor, title font) System jobs: no feedback at all
Must not block the user
![Page 11: © 2004 IBM Corporation | Boston MA, April 19, 2004 John Arthorne, Eclipse Platform Core Team The Road to Responsiveness in Eclipse 3.0](https://reader036.vdocuments.net/reader036/viewer/2022083005/56649f175503460f94c2de5f/html5/thumbnails/11.jpg)
11 The road to responsiveness | © 2004 IBM Corporation
Further reading
Examples plug-in (dev.eclipse.org/home/eclipse: org.eclipse.ui.examples.job
http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/platform-core-home/plan_concurrency.html
GUI Bloopers, Jeff Johnson – Chapter 7: Responsiveness Bloopers
Concurrent Programming in Java, Doug Lea
Modern Operating Systems, Andrew S. Tanenbaum