Life as a software engineer is so exciting! Computing power continue to rise exponentially, software demands continue to rise exponentially as well, so far so good. The bad news are that in the last decade the computing power of single threaded application remains almost flat.
If you decide to continue ignoring concurrency and multi-threading the gap between the problems you are able to solve and your hardware capabilities will continue to rise. In this session we will discuss different approaches for taming the concurrency beast, such as shared mutability,shared immutability and isolated mutability actors, STM, etc we will discuss the shortcomings and the dangers of each approach and we will compare different programming languages and how they choose to tackle/ignore concurrency.
Summary of JDK10 and What will come into JDK11なおき きしだ
Newer version is here
https://www.slideshare.net/nowokay/summary-of-jdk10-and-what-will-come-into-jdk11-99363835
Summary of JDK10
and What will come into JDK11 so far
Summary of JDK10 and What will come into JDK11なおき きしだ
Newer version is here
https://www.slideshare.net/nowokay/summary-of-jdk10-and-what-will-come-into-jdk11-99363835
Summary of JDK10
and What will come into JDK11 so far
This is a talk I did for JavaOne 2009. The focus of the talk was memory management and system monitoring with freely available tools that are in the jdk or open source.
Transactions and Concurrency Control PatternsVlad Mihalcea
30 years of RDBMS and this topic is pretty much "uncharted territory" for the vast majority of back-end developers.
This talk is relevant because data integrity is very important for many enterprise applications. At the end of this talk, the audience will get a better picture of the strengths and limitations of database systems concurrency control mechanisms.
In Java 9, Garbage First Garbage Collector (G1 GC) will be the default GC. This presentation makes an effort to help Hotspot VM users to understand the concept of G1 GC as well as provides some tuning advice.
A status update on JRuby, covering compatibility, Rails, and next-gen performance numbers. JRuby is currently the fastest way to run Rails apps, and we're doing work to make it even faster in the future.
Nonblocking (NB) algorithms are something of a Holy Grail of concurrent programming--typically very fast, even under heavy load, they come with hard guarantees about forward progress. The downside is that they are very hard to get right. This presentations authors worked on writing some nonblocking utilities (open sourced on SourceForge in the high-scale-lib project) and have made some progress toward a coding style that can be used to build a variety of NB data structures: hash tables, sets, work queues, and bit vectors. These data structures scale much better than even the concurrent JDK™ software utilities while providing the same correctness guarantees. They usually have similar overheads at the low end while scaling incredibly well on high-end hardware. The coding style is still very immature but shows clear promise. It stems from a handful of basic premises: You don't hide payload during updates; any thread can complete (or ignore) any in-progress update; use flat arrays for quick access and broadest-possible striping; and use parallel, concurrent, incremental array copy. At the core is a simple state-machine description of the update logic.
Look past the square braces and the damned header files and Objective-C -- the essential language of iOS development -- really isn't that different from other object-oriented languages. Classes, single-inheritance, polymorphism, implementation hiding... check, check, check, and check. So it's really not that difficult for old Java / Python / Ruby / C++ dogs to learn new tricks once they install Xcode, right?
To be a competent Obj-C programmer, not that hard.
To be a great Obj-C programmer... now that's another story.
In this session, we will look at traits that are unique to Objective-C, the tricks that bring out the expressiveness and power of the language. We'll also look at how to write idiomatic code that will be easily understood and maintained by other Objective-C developers. We'll look at how Automatic Reference Counting resembles but is really nothing like Garbage Collection, how properties put plain old instance variables to shame, how we loosely couple classes with delegates and notification, how blocks help us un-block our code by simplifying asynchronicity, and more.
With Java 8 adoption skyrocketing, is Scala still relevant? In our opinion, the answer is an unequivocal yes. To make our point, Tomer Gabel (system architect at Wix) will showcase practical examples where Scala's features provide a definitive advantage over Java 8. These include:
* Effective logging with traits and by-name parameters;
* Pattern matching for fun and profit;
* Type-safe, efficient serialization with type classes.
A talk given at a Wix Ukraine R&D meetup in Dnipropetrovsk, Ukraine on 6 April, 2016.
Video recording: https://youtu.be/EXxA3PlcdBg?t=3680
Sample code: https://github.com/holograph/scala-vs-java8
Presentation by Tomaz Cerar (Red Hat), delivered at the London JBoss User Group event on the 12th of February 2014.
Watch the video here: http://www.youtube.com/watch?v=eu9K5NLUKBI
Join London JBUG: http://www.c2b2.co.uk/jbug
This is a talk I did for JavaOne 2009. The focus of the talk was memory management and system monitoring with freely available tools that are in the jdk or open source.
Transactions and Concurrency Control PatternsVlad Mihalcea
30 years of RDBMS and this topic is pretty much "uncharted territory" for the vast majority of back-end developers.
This talk is relevant because data integrity is very important for many enterprise applications. At the end of this talk, the audience will get a better picture of the strengths and limitations of database systems concurrency control mechanisms.
In Java 9, Garbage First Garbage Collector (G1 GC) will be the default GC. This presentation makes an effort to help Hotspot VM users to understand the concept of G1 GC as well as provides some tuning advice.
A status update on JRuby, covering compatibility, Rails, and next-gen performance numbers. JRuby is currently the fastest way to run Rails apps, and we're doing work to make it even faster in the future.
Nonblocking (NB) algorithms are something of a Holy Grail of concurrent programming--typically very fast, even under heavy load, they come with hard guarantees about forward progress. The downside is that they are very hard to get right. This presentations authors worked on writing some nonblocking utilities (open sourced on SourceForge in the high-scale-lib project) and have made some progress toward a coding style that can be used to build a variety of NB data structures: hash tables, sets, work queues, and bit vectors. These data structures scale much better than even the concurrent JDK™ software utilities while providing the same correctness guarantees. They usually have similar overheads at the low end while scaling incredibly well on high-end hardware. The coding style is still very immature but shows clear promise. It stems from a handful of basic premises: You don't hide payload during updates; any thread can complete (or ignore) any in-progress update; use flat arrays for quick access and broadest-possible striping; and use parallel, concurrent, incremental array copy. At the core is a simple state-machine description of the update logic.
Look past the square braces and the damned header files and Objective-C -- the essential language of iOS development -- really isn't that different from other object-oriented languages. Classes, single-inheritance, polymorphism, implementation hiding... check, check, check, and check. So it's really not that difficult for old Java / Python / Ruby / C++ dogs to learn new tricks once they install Xcode, right?
To be a competent Obj-C programmer, not that hard.
To be a great Obj-C programmer... now that's another story.
In this session, we will look at traits that are unique to Objective-C, the tricks that bring out the expressiveness and power of the language. We'll also look at how to write idiomatic code that will be easily understood and maintained by other Objective-C developers. We'll look at how Automatic Reference Counting resembles but is really nothing like Garbage Collection, how properties put plain old instance variables to shame, how we loosely couple classes with delegates and notification, how blocks help us un-block our code by simplifying asynchronicity, and more.
With Java 8 adoption skyrocketing, is Scala still relevant? In our opinion, the answer is an unequivocal yes. To make our point, Tomer Gabel (system architect at Wix) will showcase practical examples where Scala's features provide a definitive advantage over Java 8. These include:
* Effective logging with traits and by-name parameters;
* Pattern matching for fun and profit;
* Type-safe, efficient serialization with type classes.
A talk given at a Wix Ukraine R&D meetup in Dnipropetrovsk, Ukraine on 6 April, 2016.
Video recording: https://youtu.be/EXxA3PlcdBg?t=3680
Sample code: https://github.com/holograph/scala-vs-java8
Presentation by Tomaz Cerar (Red Hat), delivered at the London JBoss User Group event on the 12th of February 2014.
Watch the video here: http://www.youtube.com/watch?v=eu9K5NLUKBI
Join London JBUG: http://www.c2b2.co.uk/jbug
Advanced Introduction to Java Multi-Threading - Full (chok)choksheak
Designed for the beginning Java developer to grasp advanced Java multi-threading concepts quickly. Talks mainly about the Java Memory Model and the Concurrent Utilities. This presentation is Java-specific and we intentionally omit general non-Java-specific details, such as hardware architecture, OS, native threads, algorithms, and general software design principles etc.
Intro deck from Cassandra Day Atlanta. Covers the evolution of data storage and analysis, the architecture of Cassandra, the read & write path, and using Cassandra for analytics. By Jon Haddad & Luke Tillman
A presentation at Twitter's official developer conference, Chirp, about why we use the Scala programming language and how we build services in it. Provides a tour of a number of libraries and tools, both developed at Twitter and otherwise.
Reuven Lerner's first talk from Open Ruby Day, at Hi-Tech College in Herzliya, Israel, on June 27th 2010. An overview of what makes Rails a powerful framework for Web development -- what attracted Reuven to it, what are the components that most speak to him, and why others should consider Rails for their Web applications.
These are the slides from my talk at Hulu in March 2015 discussing Apache Spark & Cassandra. I cover the evolution of data from a single machine to RDBMS (MySQL is the primary example) to big data systems.
On the Spark side, I covered batch jobs, streaming, Apache Kafka, an introduction to machine learning, clustering, logistic regression and recommendations systems (collaborative filtering).
The talk was recorded and is available on youtube: https://www.youtube.com/watch?v=_gFgU3phogQ
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)srisatish ambati
Cache & Concurrency considerations for a high performance Cassandra deployment.
SriSatish Ambati
Cassandra has hit it's stride as a distributed java NoSQL database! It's fast, it's in-memory, it's scalable, it's seda; It's eventually consistent model makes it practical for the large & growing volumes of unstructured data usecases. It is also time to run it through the filters of performance analysis. For starters it runs on the java virtual machine and inherits the capabilities and culpabilities of the platform. This presentation reviews the runtime architecture, cache behavior & performance of a real-world workload on Cassandra. We blend existing system & jvm tools to get a quick overview & a breakdown of hotspots in the get, put & update operations. We highlight the role played by garbage collection & fragmentation due to long lived objects; We investigate lock contention in the data structures under concurrent usage. Cassandra uses UDP for management & TCP for data: we look at robustness of the communication patterns during high spikes and cluster-wide events. We review Non-Blocking Hashmap modifications to Cassandra that improve concurrency & amplify performance of this frontrunner in the NoSQL space
ApacheCon2010 NA
Wed, 03 November 2010 15:00
cassandra
Writing concurrent programs that can run in multiple threads and on multiple cores is crucial but daunting. Futures provides a convenient abstraction for many problem domains. The online course "Intermediate Scala" includes an up-to-date discussion of futures and the parts of java.util.concurrent that underlie the Scala futures implementation. Unlike Java's futures, Scala futures supports composition, transformations and sophisticated callbacks.
The author is managing editor of http://scalacourses.com, which offers self-paced online courses that teach Introductory and Intermediate Scala and Play Framework.
This is an introduction to relational and non-relational databases and how their performance affects scaling a web application.
This is a recording of a guest Lecture I gave at the University of Texas school of Information.
In this talk I address the technologies and tools Gowalla (gowalla.com) uses including memcache, redis and cassandra.
Find more on my blog:
http://schneems.com
Similar to Concurrency and Multithreading Demistified - Reversim Summit 2014 (20)
Loom me up Scotty! Project Loom - What's in it for Me?Haim Yadid
Project Loom is a huge step forward in the way the JVM implements concurrency. It introduces a concurrency model that is straight forward to use without sacrificing scalability. It gets a lot of traction since it was released in preview mode in Java 19, however, it is not a silver bullet that will magically resolve everything. In this talk we will go through the essentials of the project and help understand when and where applying it will make your life as a Java developer significantly better.
“Show Me the Garbage!”, Garbage Collection a Friend or a FoeHaim Yadid
“Just leave the garbage outside and we will take care of it for you”. This is the panacea promised by garbage collection mechanisms built into most software stacks available today. So, we don’t need to think about it anymore, right? Wrong! When misused, garbage collectors can fail miserably. When this happens they slow down your application and lead to unacceptable pauses. In this talk we will go over different garbage collectors approaches and understand under which conditions they function well.
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyHaim Yadid
NEXT Insurance is a US based insurtech startup, revolutionizing the small business insurance industry. NEXT was founded 6 years ago and ever since we have been building our microservices in Kotlin. During this period we grew from a small startup with one backend developer(myself) to a $4B company with 150 backend developers. We have written over 1.2M lines of code in Kotlin and aquired long mileage with this programming language. In this talk I am going to share our experiences, insights and pains.
This talk was given in JFokus 2022
“Show Me the Garbage!”, Understanding Garbage CollectionHaim Yadid
“Just leave the garbage outside and we will take care of it for you”. This is the panacea promised by garbage collection mechanisms built into most software stacks available today. So, we don’t need to think about it anymore, right? Wrong! When misused, garbage collectors can fail miserably. When this happens they slow down your application and lead to unacceptable pauses. In this talk we will go over different garbage collectors approaches in different software runtimes and what are the conditions which enable them to function well.
Presented on Reversim summit 2019
https://summit2019.reversim.com/session/5c754052d0e22f001706cbd8
Understanding how memory is structured on the JVM ( Hotspot/OpenJDK) becomes important when you really want to troubleshoot your production environment. In this short talk I will delve into the basics of the topic and demystify some of the misconceptions.
Talk given at Java.IL user group
An old wise man once said "Understanding where the problem resides is the first step to solving it" This short talk will show how finding the nature of performance problem can be easily identified by simple JMX exposed by the JVM. And yes quoting my own sentences as old wisdom make them sound more reliable.
On September 2007 I started a journey. I left a position as a System Architect in a big Software company and started a career as an independent consultant. This have been a hell of a journey. Two years ago I returned to the warmth of the payroll (business was doing great btw as a freelancer). Along these years I found myself many times answering questions on how this is done. This lead me to the conclusion that the know how may be of an interest to the community and I want to share with you. I believe that anyone who considers becoming an independent contractor/consultant will greatly benefit from this talk.
Next Insurance was founded at the beginning of 2016, and the first lines of its production code started accumulating in May 2016. As the first back-end developer, I started writing in Java and out of curiosity was experimenting with Kotlin. Kotlin had just seen its 1.0 release two months earlier. A year later, Next Insurance’s entire back-end development team is writing all the code in Kotlin. We already have 8 microservices and several AWS lambda functions all written in Kotlin. Migration from 1.0.x to Kotlin 1.1 was smooth, and the developers are happy. This presentation covers the language’s features and why I think it is awesome and fits perfectly with my company’s architecture.
Next Insurance was founded in the beginning of 2016 and first lines of our production code started accumulating in May 2016. In the beginning I have started writing in Java and experimenting with Kotlin, which saw its 1.0 release two months earlier. 6 months later, the development of our backend services has totally shifted to Kotlin. We still keep a few classes in Java just to make sure that the integration remains seamless but the vast majority of our codebase is written in Kotlin. In this talk I will cover the language features and why I think it is awesome, from null safety to smart casts and data classes. We will also look into the future with 1.1 async/await feature and more.
Garbage collection is the most famous (infamous) JVM mechanism and it dates back to Java 1.0. Every Java developer knows about its existence yet most of the time we wish we can ignore its behavior and assume it works perfectly. Unfortunately this is not the case and if you are ignoring it, GC may hit you really hard.... in production. Furthermore the information that you may find on the web can be a lot of times misleading. In this event we will try to demystify some of the misconceptions around GC by understanding how different GC mechanisms work and how to make the right decisions in order to make them work for you.
mjprof: Monadic approach for JVM profilingHaim Yadid
A traditional Java profiler consists of two components. One collects profile data from the running application and the other is a visualization user interface to query the data. The profiler capabilities are limited by the data collected but also by the provided reports and functionality. This can be limiting when it comes to complex query of data. In this session we will introduce mjprof. It is an open source textual visualization profiler. It is extremely powerful as it enables you to compose a sequence of simple steps (monads) such as filters, transformations, group-by which let you slice and dice the data to pinpoint the problem. Working with mjprof resembles working with UNIX pipes. We will explain how to use this tool and present use cases and success stories, using this profiler in the last months. mjprof is written in Java and can be found on github as part of the AdoptOpenJDK project.
This talk was given in ilJUG on the 29th of July 2014 and discusses the new Java8 StampedLock class. It compares it to different locking mechanism is Java and shows some insights deduced from a simple benchmark
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
2. About
Me:
Haim
Yadid
•21 Years of SW development experience
•Performance Expert
•Consulting R&D Groups
•Training: Java Performance Optimization
3.
4. Moore’s
Law
•Number of transistors doubles constantly
•CPU frequency à
stalled.
•Performance boost through parallelism
5. Yes….
But
•Performance is not a problem anymore
•We prefer commodity hardware
•We have Hadoop and Big Data!!!
•Hardware is cheap.
•Several processes will do
•My programming language
will protect me
7. Concurrency
•Decomposition of your program
into independently executing processes
•About structure
•About design
•It is not something you code it is
something you architect
14. Liveliness
Problems
•Deadlock
•Starvation
•Waiting for a train that will never come
func count() {
for i := 0; i < 1000; i++ {
fmt.Println(i)
time.Sleep(10 * time.Millisecond)
}
}
func main() {
go count()
time.Sleep(3000 * time.Millisecond)
for {}
GOMAXPROCS=2
}
Go
15. Data
Races
•Inopportune interleaving
•Stale values
•Loosing updates
•Infinite loops
class Foo {
private HashSet h = new HashSet();
!
}
!
boolean introduceNewVal(Object v) {
if (!h.contains(v)) {h.add(v); return true; }
return false;
}
Java
17. Whats
wrong
here?
•IncrementX accessed from ThreadX
•IncrementY accessed from Thread Y
•An aggregator thread will read both
Class
T
{
volatile
int
x
=
0;
volatile
int
y=0;
!
long incrementX() { x++; }
long incrementY() { y++; }
}
False
sharing:
cache
coherency
-‐>
hitting
same
cache
line
Java
23. Serial
Execution
•Three queries to DB executed
•In Serial
•Long response time
doGet(req,resp) {
rs1 = runQuery1()
rs2 = runQuery2()
rs3 = runQuery3()
resp.write(mergeResults(rs1,rs2,rs3))
}
Can
be
parallelized
Pseudo(Java)
24. Create
Threads
•Run three queries in parallel…..
•but:
doGet(req,resp) {
q1 = new Query();
new Thread(q1).start();
q2 = new Query();
new Thread(q2).start();
q3 = new Query();
new Thread(q3).start();
!
}
rs1 = q1.getRs();
rs2 = q2.getRs();
rs3 = q3.getRs();
resp.write(mergeResults(rs1,rs2,rs3));
Thread
leak
+
Thread
creation
overhead
+
data
races
Pseudo(Java)
25. Thread
Pool
doGet(req,resp) {
ExecutorService e = Executors.newFixedThreadPool(3);
ArrayList tasks = …;
tasks.add(new QueryTask(Query1)) …. 3
List<Future<Integer>> fs;
fs = e.invokeAll(tasks); // invoke all in parallel
ArrayList results = …
for (Future<Integer> f : l) { // collect results
if (f.isDone()) {
results.add(f.get());
}
}
resp.write(mergeResults(results));
}
Thread
pool
leak
+
Thread
pool
creation
overhead
Pseudo(Java)
26. Thread
Pool
2
static ExecutorService e = Executors.newFixedThreadPool(3);
!
doGet(req,resp) {
ArrayList tasks = …;
tasks.add(new QueryTask(Query1)) …. 3
List<Future<Integer>> fs;
fs = e.invokeAll(tasks); // invoke all in parallel
!
}
ArrayList results = …
for (Future<Integer> f : l) { // collect results
if (f.isDone()) {
res.add(f.get());
}
}
resp.write(mergeResults(results));
Size
?/
share
thread
pool?
/
name
thread
pool
threads
Pseudo(Java)
27. Same
Example
With
Go
func
execQuery(query
string,
c
chan
*Row)
{
c
<-‐
db.Query(query)
}
!
func
doGet(req,resp) {
c := make(chan *Row)
go execQuery(query1,c)
go execQuery(query2,c)
go execQuery(query3,c)
for i := 0; i<3 ; i++
combineRs(rs <-c)
}
Pseudo(Go)
28.
29. State
Management
•Eventually we need to have state
•It is easy to deal with state when we have
one Sid
•But what happens when there are several
•We have three approaches
•Most are familiar with only one
33. Visibility
•Change made by sid1 is visible to sid2?
•Solutions
•volatile keyword
•Memory Model(Happens before)
Memory
L3
cache
L2
cache
L1
cache
•compiler reordering
Registers
•Caches
CPU
•Not so simple
34. Atomicity
•What can be done in a single step ?
•CAS constructs (Compare and swap)
•AtomicInteger
•AtomicLong
•ConcurrenctHashMap putIfAbsent
35. Atomicity
is
not
Viral
•An (almost) real example
•A non transactional database
•Balance per user
•Use atomicity to solve the problem
class
User
{
private
AtomicLong
balance
=
…..
!
int updateBalance(int diff) {
long temp = balance.addAndGet(diff);
setToDB(temp);
}
}
Java
39. STM
(Optimistic)
•Software Transactional Memory
•Transactional semantics ACI: (not Durable)
•Atomic,
•Consistent and
•Isolated
•No deadlocks - when collision retry!
•Clojure refs , Akka refs
STM
performance
problem
when
there
are
too
many
mutations.
41. Mutliverse
STM
Example
import org.multiverse.api.references.*;
import static org.multiverse.api.StmUtils.*;
!
!
!
public class Account{
private final TxnRef<Date> lastUpdate;
private final TxnInteger balance;
public Account(int balance){
this.lastUpdate = newTxnRef<Date>(new Date());
this.balance = newTxnInteger(balance);
}
Java
42. Mutliverse
STM
Example
public void incBalance(final int amount, final Date date){
atomic(() ->{
balance.inc(amount);
lastUpdate.set(date);
!
if(balance.get()<0){
throw new IllegalStateException("Not enough money");
}
});
}
}
Java8
43. Mutliverse
STM
Example
!
public static void transfer(final Account from, final Account to, final int amount){ Java8
atomic(()->{
Date date = new Date();
from.incBalance(-amount, date);
to.incBalance(amount, date);
});
}
Retry
ahead
beware
of
side
effects
44.
45. Pure
Immutability
•We have shared state
•But Shared state is read only (after
construction)
•No concurrency issues
•No deadlocks
•No race conditions
•No stale values
•Optimal for cache
47. Immutable
Object
Example
Object cannot be changed after
construction
all fields are final
public final Class MySet {
private final Set<String> vals = new HashSet<String>();
public MySet(String names[]) {
for(name:names) vals.add(name);
}
public boolean containsVal(String name);…..
}
Java
48. CopyOnWrite
Collections
•Any changes to it will create a new copy
•Safe
•Fast read, read without synchronisation
•Iteration is fast
•do not support remove() set() add()
Bad
performance
when
mutation
rate
is
high
52. Example
Customization
Cache
•A Web application server
•Serving Complicated and customisable UI
•Each user has it’s own customization
(potentially)
•Classic for immutable collection
•Low mutation rate
•High read rate
53. Example
Customization
Cache
•Customization Data is immutable
•Customization Data HashMap is a
Persistent Map
•Cache is represented by a single STM
reference
•Update will fail if two are performing it
at once
54. Immutability
and
GC
•Immutability is great
•But: Generates of a lot of objects
•When done for short lived objects GC can
cope with it
•Long lived immutable objects/collections
which change frequently may cause GC to
have low throughput and high pause times
55.
56. Isolated
Mutability
•No shared state
•Each Sid has its own pile of sand
•Message passing between Sids
•Prefer passing immutable objects
60. Building
a
Monitoring
System
•Monitoring System (e.g. Nagios)
•~100k of monitors
•running periodically
•Each one has a state.
•Consumers are able to query state.
•Some monitors may affect other monitor
state
62. Monitor
Actors
•MonitorStateActor(MSA)
•Alway readys to be queried
•State updated by message from MRA
•Stateless
•MonitorRecalculateActor(MRA)
•Maybe recalculating and not responsive
•Stateful
•Supervises MSA
63. MonitorsCache
•An immutable cache - holds all actor refs
•Single view of the world.
•Used by SchedulerActor and Query
Actor
•May have several objects managed By
STM
65. Further
Reading
•Java Concurrency In Practice /Brian Goetz
•Effective Akka / Jamie Allen
•Clojure High Performance Programming /
Shantanu Kumar
•Programming Concurrency on the JVM:
Mastering Synchronization, STM, and
Actors /Subramaniam, Venkat