SlideShare a Scribd company logo
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.

More Related Content

What's hot

Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
erdemergin
 
Android - Preventing common memory leaks
Android - Preventing common memory leaksAndroid - Preventing common memory leaks
Android - Preventing common memory leaks
Ali Muzaffar
 
1 aleksandr gritsevski - attd example using
1   aleksandr gritsevski - attd example using1   aleksandr gritsevski - attd example using
1 aleksandr gritsevski - attd example using
Ievgenii 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 answers
kavinilavuG
 
MeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenmentMeetJS Summit 2016: React.js enlightenment
MeetJS Summit 2016: React.js enlightenment
Artur 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 Answers
Ajit 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 Insight
iAppSecure Solutions
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJSTroy Miles
 
Testing React Applications
Testing React ApplicationsTesting React Applications
Testing React Applications
stbaechler
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Trey 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 rendering
Maurice 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_ yrs
Ajit 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 2
Matt Raible
 
EasyMock for Java
EasyMock for JavaEasyMock for Java
EasyMock for Java
Deepak Singhvi
 
Easymock Tutorial
Easymock TutorialEasymock Tutorial
Easymock Tutorial
Sbin m
 
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Code
slicklash
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
sgleadow
 
The State of Wicket
The State of WicketThe State of Wicket
The State of Wicket
Martijn Dashorst
 
Unit Testing 101
Unit Testing 101Unit Testing 101
Unit Testing 101
Dave Bouwman
 

What's hot (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
 

Similar to 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 Java
Coverity
 
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
香港六合彩 » SlideShare
yayao
 
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
Elixir Club
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
Troy Miles
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
hchen1
 
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 important
elumalai7
 
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
aragozin
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
Sivakumar 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 Snabbkaffe
EMQ
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
Michael 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 Bytecode
Teodoro Cipresso
 
Testing w-mocks
Testing w-mocksTesting w-mocks
Testing w-mocks
Macon Pegram
 
How and what to unit test
How and what to unit testHow and what to unit test
How and what to unit test
Eugenio 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-Frameworks
Thomas Fuchs
 

Similar to 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
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 

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)