SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Concurrency in Eclipse:Best Practices and Gotchas Andrew McCulloch andrew.mcculloch@oracle.com Carlin Rogers carlin.rogers@oracle.com
About Us Andrew McCulloch Andrew.McCulloch@oracle.com Principle Member of Technical Staff at Oracle working on the Oracle Enterprise Pack for Eclipse (OEPE) Lead on AppXray feature which manages dependencies in a user's workspace Area of interest include concurrency and performance tuning Carlin Rogers Carlin.Rogers@oracle.com Principle Member of Technical Staff at Oracle working on the Oracle Enterprise Pack for Eclipse (OEPE) Committer on the JavaServer Faces Tools Project at Eclipse Areas of interest include web frameworks, concurrency, and performance tuning
Reactions to Concurrency "...we always get deadlock messages, and have no idea what they mean (in context) and we just ignore them.“ 			- Anonymous SQL Server Developer
Agenda Overview concurrency Describe our project and experience Problems and gotchas we encountered Practical debugging tips Best practices Questions
Java Concurrency Overview ,[object Object]
java.lang.Thread, java.lang.Runnable
synchronized keyword
java.util.concurrent package (Java SE 5)
Eclipse Building Blocks
org.eclipse.core.runtime.jobs.Job
org.eclipse.core.runtime.jobs.ISchedulingRule
org.eclipse.core.runtime.jobs.ILock
org.eclipse.swt.widgets.Display#asyncExec,[object Object]
Interleaving of threads results in undefined or incorrect state
Deadlock / Livelock
Progress can not be made due to competing locks (deadlock), broken lock avoidance (livelock)
Starvation / Fairness
Starvation usually occurs when the scheduling algorithm gives priority to one thread over another, repeatedly,[object Object]
Problems We Encountered Race Conditions Lazy initialization of, and access to, models that were not thread safe - uncontrolled concurrent access to mutable data.
Race Conditions Exceptions from EMF models Exceptions during access/initialization of EMF Models [Bugzilla 228748] java.lang.NullPointerException  at org.eclipse.emf.ecore.util.EContentAdapter.addAdapter(EContentAdapter.java:352)  at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:225)  at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:188)  at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:77) at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:646)  at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:626)  at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:129)  at org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager.addFacesConfigChangeAdapter(     JSFAppConfigManager.java:769)  … at org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager.getFacesConfigModels( JSFAppConfigManager.java:409)
Debugging Tip Intermittent bugs can be very difficult to reproduce in a system test. Difficult to reproduce race condition in EMF code using debugger. Narrow the scope - create simple controlled test of the specific code path in the stack trace from the exception. Example: launch multiple threads, each calling the JSFAppConfigManager.getFacesConfigModels() method
Best Practices “Synchronize access to shared mutable data” – Joshua Bloch
Problems We Encountered Race Conditions Lazy initialization of, and access to, models that were not thread safe - uncontrolled concurrent access to mutable data. Deadlocks Know your third party code - it may take a scheduling rule.
Lock Order and Third Party Code Deadlocks from calls in other libraries that require a scheduling rule. For example… Thread A - AppXRay Job Thread B – Main - Calls beginRule with the IProject as the scheduling rule. - UI component calls to access information from shared model, enters synchronized block. - Tries to access information from shared model, waits to enter synchronized block locked by Thread B. - Third party code requires JDT to resolve classpaths for the projects, and tries to take the IProjectscheduling rule.
Debugging Tip ,[object Object]
Eclipse Debugger - turn on "Show Monitors" to see locks for synchronized blocks
Mission Control with Oracle JRockit JVM
jstack with a process ID for a thread dump
Create a simple test case that explicitly launches two jobs. Put break points in strategic places to control timing of taking the locks to force the deadlock condition. Use this technique to confirm a fix.,[object Object]
Problems We Encountered Race Conditions Lazy initialization of, and access to, models that were not thread safe - uncontrolled concurrent access to mutable data. Deadlocks Know your third party code - it may take a scheduling rule. Thread Starvation JobManager.waitForRun prevented jobs with complex relationships from running in a timely manner.

Weitere ähnliche Inhalte

Was ist angesagt?

Android - Preventing common memory leaks
Android - Preventing common memory leaksAndroid - Preventing common memory leaks
Android - Preventing common memory leaksAli Muzaffar
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example usingIevgenii Katsan
 
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...Alan Richardson
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answerskavinilavuG
 
MeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentMeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentArtur Szott
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersAjit Jadhav
 
SQL and XPATH Injection with Fusion Lite Insight
SQL and XPATH Injection with Fusion Lite InsightSQL and XPATH Injection with Fusion Lite Insight
SQL and XPATH Injection with Fusion Lite InsightiAppSecure Solutions
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJSTroy Miles
 
Testing React Applications
Testing React ApplicationsTesting React Applications
Testing React Applicationsstbaechler
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring BootTrey Howard
 
Getting started with React Suspense and concurrent rendering
Getting started with React Suspense and concurrent renderingGetting started with React Suspense and concurrent rendering
Getting started with React Suspense and concurrent renderingMaurice De Beijer [MVP]
 
Ajit jadhav automation_qa_4_ yrs
Ajit jadhav automation_qa_4_ yrsAjit jadhav automation_qa_4_ yrs
Ajit jadhav automation_qa_4_ yrsAjit Jadhav
 
Migrating from Struts 1 to Struts 2
Migrating from Struts 1 to Struts 2Migrating from Struts 1 to Struts 2
Migrating from Struts 1 to Struts 2Matt Raible
 
Easymock Tutorial
Easymock TutorialEasymock Tutorial
Easymock TutorialSbin m
 
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Codeslicklash
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testingsgleadow
 

Was ist angesagt? (20)

Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Android - Preventing common memory leaks
Android - Preventing common memory leaksAndroid - Preventing common memory leaks
Android - Preventing common memory leaks
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example using
 
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answers
 
MeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentMeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenment
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
SQL and XPATH Injection with Fusion Lite Insight
SQL and XPATH Injection with Fusion Lite InsightSQL and XPATH Injection with Fusion Lite Insight
SQL and XPATH Injection with Fusion Lite Insight
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
 
Testing React Applications
Testing React ApplicationsTesting React Applications
Testing React Applications
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Getting started with React Suspense and concurrent rendering
Getting started with React Suspense and concurrent renderingGetting started with React Suspense and concurrent rendering
Getting started with React Suspense and concurrent rendering
 
Ajit jadhav automation_qa_4_ yrs
Ajit jadhav automation_qa_4_ yrsAjit jadhav automation_qa_4_ yrs
Ajit jadhav automation_qa_4_ yrs
 
Migrating from Struts 1 to Struts 2
Migrating from Struts 1 to Struts 2Migrating from Struts 1 to Struts 2
Migrating from Struts 1 to Struts 2
 
EasyMock for Java
EasyMock for JavaEasyMock for Java
EasyMock for Java
 
Easymock Tutorial
Easymock TutorialEasymock Tutorial
Easymock Tutorial
 
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Code
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
 
The State of Wicket
The State of WicketThe State of Wicket
The State of Wicket
 
Unit Testing 101
Unit Testing 101Unit Testing 101
Unit Testing 101
 

Ähnlich wie Concurrency in Eclipse: Best Practices and Gotchas

Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Cωνσtantίnoς Giannoulis
 
Concurrency Errors in Java
Concurrency Errors in JavaConcurrency Errors in Java
Concurrency Errors in JavaCoverity
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaWO Community
 
香港六合彩 » SlideShare
香港六合彩 » SlideShare香港六合彩 » SlideShare
香港六合彩 » SlideShareyayao
 
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Elixir Club
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day trainingTroy Miles
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
AEM Clean Code - Miklos Csere
AEM Clean Code - Miklos Csere AEM Clean Code - Miklos Csere
AEM Clean Code - Miklos Csere Miklos Csere
 
Gnizr Architecture (for developers)
Gnizr Architecture (for developers)Gnizr Architecture (for developers)
Gnizr Architecture (for developers)hchen1
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testabilitydrewz lin
 
System verilog important
System verilog importantSystem verilog important
System verilog importantelumalai7
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherencearagozin
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java PlatformSivakumar Thyagarajan
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4Billie Berzinskas
 
Introduction to Snabbkaffe
Introduction to SnabbkaffeIntroduction to Snabbkaffe
Introduction to SnabbkaffeEMQ
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
Applying Anti-Reversing Techniques to Java Bytecode
Applying Anti-Reversing Techniques to Java BytecodeApplying Anti-Reversing Techniques to Java Bytecode
Applying Anti-Reversing Techniques to Java BytecodeTeodoro Cipresso
 
How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit testEugenio Lentini
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksThomas Fuchs
 

Ähnlich wie Concurrency in Eclipse: Best Practices and Gotchas (20)

Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
 
Concurrency Errors in Java
Concurrency Errors in JavaConcurrency Errors in Java
Concurrency Errors in Java
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
 
香港六合彩 » SlideShare
香港六合彩 » SlideShare香港六合彩 » SlideShare
香港六合彩 » SlideShare
 
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
AEM Clean Code - Miklos Csere
AEM Clean Code - Miklos Csere AEM Clean Code - Miklos Csere
AEM Clean Code - Miklos Csere
 
Gnizr Architecture (for developers)
Gnizr Architecture (for developers)Gnizr Architecture (for developers)
Gnizr Architecture (for developers)
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherence
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4
 
Introduction to Snabbkaffe
Introduction to SnabbkaffeIntroduction to Snabbkaffe
Introduction to Snabbkaffe
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
Applying Anti-Reversing Techniques to Java Bytecode
Applying Anti-Reversing Techniques to Java BytecodeApplying Anti-Reversing Techniques to Java Bytecode
Applying Anti-Reversing Techniques to Java Bytecode
 
Testing w-mocks
Testing w-mocksTesting w-mocks
Testing w-mocks
 
How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit test
 
Zepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-FrameworksZepto and the rise of the JavaScript Micro-Frameworks
Zepto and the rise of the JavaScript Micro-Frameworks
 

Kürzlich hochgeladen

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Kürzlich hochgeladen (20)

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Concurrency in Eclipse: Best Practices and Gotchas

  • 1. Concurrency in Eclipse:Best Practices and Gotchas Andrew McCulloch andrew.mcculloch@oracle.com Carlin Rogers carlin.rogers@oracle.com
  • 2. About Us Andrew McCulloch Andrew.McCulloch@oracle.com Principle Member of Technical Staff at Oracle working on the Oracle Enterprise Pack for Eclipse (OEPE) Lead on AppXray feature which manages dependencies in a user's workspace Area of interest include concurrency and performance tuning Carlin Rogers Carlin.Rogers@oracle.com Principle Member of Technical Staff at Oracle working on the Oracle Enterprise Pack for Eclipse (OEPE) Committer on the JavaServer Faces Tools Project at Eclipse Areas of interest include web frameworks, concurrency, and performance tuning
  • 3.
  • 4. Reactions to Concurrency "...we always get deadlock messages, and have no idea what they mean (in context) and we just ignore them.“ - Anonymous SQL Server Developer
  • 5. Agenda Overview concurrency Describe our project and experience Problems and gotchas we encountered Practical debugging tips Best practices Questions
  • 6.
  • 14.
  • 15. Interleaving of threads results in undefined or incorrect state
  • 17. Progress can not be made due to competing locks (deadlock), broken lock avoidance (livelock)
  • 19.
  • 20. Problems We Encountered Race Conditions Lazy initialization of, and access to, models that were not thread safe - uncontrolled concurrent access to mutable data.
  • 21. Race Conditions Exceptions from EMF models Exceptions during access/initialization of EMF Models [Bugzilla 228748] java.lang.NullPointerException at org.eclipse.emf.ecore.util.EContentAdapter.addAdapter(EContentAdapter.java:352) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:225) at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:188) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:77) at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:646) at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:626) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:129) at org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager.addFacesConfigChangeAdapter( JSFAppConfigManager.java:769) … at org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager.getFacesConfigModels( JSFAppConfigManager.java:409)
  • 22. Debugging Tip Intermittent bugs can be very difficult to reproduce in a system test. Difficult to reproduce race condition in EMF code using debugger. Narrow the scope - create simple controlled test of the specific code path in the stack trace from the exception. Example: launch multiple threads, each calling the JSFAppConfigManager.getFacesConfigModels() method
  • 23. Best Practices “Synchronize access to shared mutable data” – Joshua Bloch
  • 24. Problems We Encountered Race Conditions Lazy initialization of, and access to, models that were not thread safe - uncontrolled concurrent access to mutable data. Deadlocks Know your third party code - it may take a scheduling rule.
  • 25. Lock Order and Third Party Code Deadlocks from calls in other libraries that require a scheduling rule. For example… Thread A - AppXRay Job Thread B – Main - Calls beginRule with the IProject as the scheduling rule. - UI component calls to access information from shared model, enters synchronized block. - Tries to access information from shared model, waits to enter synchronized block locked by Thread B. - Third party code requires JDT to resolve classpaths for the projects, and tries to take the IProjectscheduling rule.
  • 26.
  • 27. Eclipse Debugger - turn on "Show Monitors" to see locks for synchronized blocks
  • 28. Mission Control with Oracle JRockit JVM
  • 29. jstack with a process ID for a thread dump
  • 30.
  • 31. Problems We Encountered Race Conditions Lazy initialization of, and access to, models that were not thread safe - uncontrolled concurrent access to mutable data. Deadlocks Know your third party code - it may take a scheduling rule. Thread Starvation JobManager.waitForRun prevented jobs with complex relationships from running in a timely manner.
  • 32. Scheduler issues [Bugzilla 320329] Not a typical Thread Starvation case, but illustrates a point. Job dependencies can be complex when multiple jobs launch in response to a single event. In the UI progress dialog the running job appeared to be deadlocked when it was not at fault. Dynamic Analysis tools can pinpoint the true problem Our profiling tool pointed out that a loop in the scheduler was executed millions of times. The issue was in the Job scheduler in open source code After several iterations at a patch the issue was resolved
  • 33. Debugging Tip Be familiar with dynamic analysis tools. We use several including Oracle JRockit Mission Control and third-party tools. Don’t ignore org.eclipse code in your analysis. Eclipse is a quality product but bugs do get through and the community can help resolve them.
  • 34. Best Practices “Synchronize access to shared mutable data” Enforce a consistent locking order. “Avoid excessive synchronization” Don’t be hesitant to debug into open source code, submit questions, bugs, and patches. This make your product and Eclipse better
  • 35. Gotchas Job.yieldRule() Third party code may move your job to waiting state and yield the scheduling rule to other jobs to avoid potential deadlocks. (bug 283449)
  • 36. Job.yieldRule() Thread dump from deadlock java.lang.Object.wait(Native Method) at org.eclipse.core.internal.jobs.ThreadJob.waitForRun(ThreadJob.java:270) at org.eclipse.core.internal.jobs.ThreadJob.joinRun(ThreadJob.java:199) at org.eclipse.core.internal.jobs.JobManager.yieldRule(JobManager.java:1398) at org.eclipse.core.internal.jobs.InternalJob.yieldRule(InternalJob.java:600) at org.eclipse.core.runtime.jobs.Job.yieldRule(Job.java:709) at org.eclipse.wst.sse.core.internal.model.ModelManagerImpl$ SharedObject.waitForLoadAttempt(ModelManagerImpl.java:139) at org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.getExistingModel( ModelManagerImpl.java:1137)
  • 37.
  • 38. Look for yieldRule() in the stack.
  • 39. Determine if you can move the call to third party code outside of the synchronization.
  • 40.
  • 41. Gotchas Job.yieldRule() Third party code may move your job to waiting state and yield the scheduling rule to other jobs to avoid potential deadlocks. (bug 283449) EventLoopProgressMonitor Starting a rule on the UI thread will have unintended consequences regardless of how long the rule is held.
  • 42. Event loop will be interleaved Acquiring a scheduling rule from the UI thread may appear as a UI freeze. Alternatively in some instances acquiring a scheduling rule on the UI thread may cause calls to the progress monitor to execute other UI events which will eliminate the appearance of a freeze but can cause errors with non-reentrant code. RunnableWithProgress also replaces null progress monitors.
  • 43. Debugging Tip Analyze stack trace for EventLoopProgressMonitor Look for entries on the stack that you would not expect to be executing from within your code. Look for tell-tale exception “Attempted reentrant call …” Determine where the scheduling rule is acquired Can that code be moved off of the UI thread? Can the UI widget be redesigned to update asynchronously?
  • 44. Best Practices “Synchronize access to shared mutable data” Enforce a consistent locking order. “Avoid excessive synchronization” Don’t be hesitant to work with open source code. Use ILock for synchronization Run as little as possible on the UI thread. Move code requiring ISchedulingRules to a Job.
  • 45. In Conclusion… “Synchronize access to shared mutable data” Enforce a consistent locking order. “Avoid excessive synchronization” Don’t be hesitant to work with open source code. Use ILock for synchronization Run as little as possible on the UI thread. Move code requiring ISchedulingRules to a Job.
  • 46. Suggested References Java Concurrency in Practice Brian Goetz (2006) Effective Java (2nd Edition) Joshua Bloch (2008) Concurrent Programming in Java Doug Lea (1999)