SlideShare a Scribd company logo
1 of 26
Parallel first-order operations
Sina Madani, Dimitris Kolovos, Richard Paige
{sm1748, dimitris.kolovos, richard.paige}@york.ac.uk
Enterprise Systems, Department of Computer Science
1OCL 2018, Copenhagen
Outline
• Background and related work
• Epsilon Object Language (EOL)
• Parallelisation challenges and solutions
• Performance evaluation
• Future work
• Questions
2OCL 2018, Copenhagen
Motivation
• Scalability is an active research area in model-driven engineering
• Collaboration and versioning
• Persistence and distribution
• Continuous event processing
• Queries and transformations
• Very large models / datasets common in complex industrial projects
• First-order operations frequently used in model management tasks
• Diminishing single-thread performance, increasing number of cores
• Vast majority of operations on collections are pure functions
• i.e. inherently thread-safe and parallelisable
3OCL 2018, Copenhagen
Related Work
• Parallel ATL (Tisi et al., 2013)
• Task-parallel approach to model transformation
• Parallel OCL (Vajk et al., 2011)
• Automated parallel code generation based on CSP and C#
• Lazy OCL (Tisi et al., 2015)
• Iterator-based lazy evaluation of expressions on collections
• Parallel Streams (Java 8+, 2013)
• Rich and powerful API for general queries and transformations
• Combines lazy semantics with divide-and-conquer parallelism
4OCL 2018, Copenhagen
Epsilon Object Language (EOL)
• Powerful imperative programming constructs
• Independent of underlying modelling technology
• Interpreted, model-oriented Java + OCL-like language
• Base query language of Epsilon
• Global variables
• Cached operations
• ...and more
5OCL 2018, Copenhagen
General challenges / assumptions
• Need to capture state prior to parallel execution
• e.g. Any declared variables need to be accessible
• Side-effects need not be persisted
• e.g. through operation invocations
• Operations should not depend on mutable global state
• Caches need to be thread-safe
• Through synchronization or atomicity
• Mutable engine internals (e.g. frame stack) are thread-local
• Intermediate variables’ scope is limited to each parallel “job”
• No nested parallelism
6OCL 2018, Copenhagen
Collection<T> select (Expression<Boolean> predicate, Collection<T> source)
• Filters the collection based on a predicate applied to each element
var jobs = new ArrayList<Callable<Optional<T>>>(source.size());
for (T element : source) {
jobs.add(() -> {
if (predicate.execute(element))
return Optional.of(element);
else return Optional.empty();
});
}
context.executeParallel(jobs).forEach(opt -> opt.ifPresent(results::add));
return results;
OCL 2018, Copenhagen 7
context.executeParallel (ordered)
EolThreadPoolExecutor executorService = getExecutorService();
List<Future<T>> futureResults = jobs.stream()
.map(executorService::submit).collect(Collectors.toList());
List<T> actualResults = new ArrayList<>(futureResults.size());
for (Future<T> future : futureResults) {
actualResults.add(future.get());
}
return actualResults;
OCL 2018, Copenhagen 8
T selectOne (Expression<Boolean> predicate, Collection<T> source)
• Finds any* element matching the predicate
• Same as select, except with short-circuiting
for (T element : source) {
jobs.add(() -> {
if (predicate.execute(element))
context.completeShortCircuit(Optional.of(element));
});
}
Optional<T> result = context.awaitShortCircuit(jobs);
hasResult = result != null;
if (hasResult) return result.get();
OCL 2018, Copenhagen 9
context.shortCircuit
• ExecutionStatus object used for signalling completion
• “AwaitCompletion” thread waits for completion of jobs
• Also checks whether the completion status has been signalled
• Main thread waits for the ExecutionStatus to be signalled
• Call to context.completeShortCircuit() signals the ExecutionStatus
• “AwaitCompletion” terminates upon interruption
• After control returns to main thread, remaining jobs are cancelled
OCL 2018, Copenhagen 10
Boolean nMatch (Expression<Boolean> predicate, int n, Collection<T> source)
• Returns true iff the collection contains exactly n elements satisfying
the predicate
AtomicInteger matches = new AtomicInteger(), evaluated = new AtomicInteger();
for (T element : source) {
jobs.add(() -> {
int evaluatedInt = evaluated.incrementAndGet();
if (predicate.execute(element) && (matches.incrementAndGet() > n ||
sourceSize – evaluatedInt < n - matches.get())) {
context.completeShortCircuit();
}
});
}
return matches.get() == n;
OCL 2018, Copenhagen 11
Boolean exists (Expression<Boolean> predicate, Collection<T> source)
• Returns true if any element matches the predicate
• Same as selectOne, but returns a Boolean
var selectOne = new ParallelSelectOneOperation();
selectOne.execute(source, predicateExpression);
return selectOne.hasResult();
OCL 2018, Copenhagen 12
Boolean forAll (Expression<Boolean> predicate, Collection<T> source)
• Returns true iff all elements match the predicate
• Delegate to nMatch to benefit from short-circuiting
var nMatch = new ParallelNMatchOperation(source.size());
return nMatch.execute(source, predicateExpression);
• Alternatively, delegate to exists with inverted predicate
OCL 2018, Copenhagen 13
Collection<R> collect (Expression<R> mapFunction, Collection<T> source)
• Transforms each element T into R, returning the result collection
• Computationally similar to select, but simpler
• No wrapper required, since we’re performing a one-to-one mapping
var jobs = new ArrayList<Callable<R>>(source.size());
for (T element : source) {
jobs.add(() -> mapFunction.execute(element));
}
context.executeParallel(jobs).forEach(results::add);
return results;
OCL 2018, Copenhagen 14
List<T> sortBy (Expression<Comparable<?>> property, Collection<T> source)
• Sorts the collection according to the derived Comparable
• Maps each element to a Comparable using collect
• Sorts the derived collection based on the Comparator property of
each derived element
• Sorting can be parallelised using java.util.Arrays.parallelSort
• Divide-and-conquer approach, sequential threshold = 8192 elements
OCL 2018, Copenhagen 15
Map<K, Collection<T>> mapBy (Expression<K> keyExpr, Collection<T> source)
• Groups elements based on the derived key expression
var jobs = new ArrayList<Callable<Map.Entry<K, T>>>(source.size());
for (T element : source) {
jobs.add(() -> {
K result = keyExpr.execute(element);
return new SimpleEntry<>(result, element);
});
}
Collection<Map.Entry<K, T>> intermediates = context.executeParallel(jobs);
Map<K, Sequence<T>> result = mergeByKey(intermediates);
return result;
OCL 2018, Copenhagen 16
Testing for correctness
• EUnit – JUnit-style tests for Epsilon
• Testing of all operations, with corner cases
• Equivalence test of sequential and parallel operations
• Testing of scope capture, operation calls, exception handling etc.
• Repeated many times with no failures
OCL 2018, Copenhagen 17
OCL 2018, Copenhagen 18
Performance evaluation
19
• Execution time on X axis
• Speedup indicated on data points (higher is better)
• Number of threads indicated in parentheses on Y axis
• All tests performed on following system:
• AMD Threadripper 1950X (16 core / 32 threads)
• 32 GB (4 x 8GB) DDR4-3000MHz RAM
• Oracle JDK 11 HotSpot VM
• Fedora 28 OS
OCL 2018, Copenhagen
20OCL 2018, Copenhagen
1
12.438
13.334
0 1000 2000 3000 4000 5000 6000 7000 8000 9000
Sequential
Parallel (16)
Parallel (32)
Execution time (seconds)
select (3.53 million elements)
OCL 2018, Copenhagen 21
OCL 2018, Copenhagen 22
Future Work
• closure
• aggregate and iterate
• Identify bottlenecks to improve performance
• Combine with lazy solution
• More comprehensive performance evaluation
• Test all operations
• Compare with Eclipse OCL
• More varied and complex models / queries
23OCL 2018, Copenhagen
Questions?
24
sm1748@york.ac.uk
OCL 2018, Copenhagen
eclipse.org/epsilon
• Data-parallelisation of first-order operations on collections
• Short-circuiting operations more complex to deal with
• Stateful operations, such as mapBy, require different approach
• Significant performance improvement with more cores
• Open-source
github.com/epsilonlabs/parallel-erl
Thread-local base delegation example
• Can be used to solve variable scoping
• Each thread has its own frame stack (used for storing variables)
• Each thread-local frame stack has a reference to the main thread’s
frame stack
• If a variable in the thread-local frame stack can’t be found, look in the
main thread frame stack
• Main thread frame stack should be thread-safe, but thread-local
frame stacks needn’t be
25OCL 2018, Copenhagen
Control Flow Traceability
• Different parts of the program could be executing simultaneously
• Need execution trace for all threads
• Solution:
• Each thread has its own execution controller
• Record the trace when exception occurs
• Parallel execution terminates when any thread encounters an exception
26OCL 2018, Copenhagen

More Related Content

What's hot

Machine Learning with Apache Flink at Stockholm Machine Learning Group
Machine Learning with Apache Flink at Stockholm Machine Learning GroupMachine Learning with Apache Flink at Stockholm Machine Learning Group
Machine Learning with Apache Flink at Stockholm Machine Learning GroupTill Rohrmann
 
Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and IterationsSameer Wadkar
 
Parallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowParallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowCodecamp Romania
 
Unified Stream & Batch Processing with Apache Flink (Hadoop Summit Dublin 2016)
Unified Stream & Batch Processing with Apache Flink (Hadoop Summit Dublin 2016)Unified Stream & Batch Processing with Apache Flink (Hadoop Summit Dublin 2016)
Unified Stream & Batch Processing with Apache Flink (Hadoop Summit Dublin 2016)ucelebi
 
Flink Gelly - Karlsruhe - June 2015
Flink Gelly - Karlsruhe - June 2015Flink Gelly - Karlsruhe - June 2015
Flink Gelly - Karlsruhe - June 2015Andra Lungu
 
Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...
Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...
Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...ucelebi
 
Predictive Datacenter Analytics with Strymon
Predictive Datacenter Analytics with StrymonPredictive Datacenter Analytics with Strymon
Predictive Datacenter Analytics with StrymonVasia Kalavri
 
Deep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
Deep Dive Into Catalyst: Apache Spark 2.0’s OptimizerDeep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
Deep Dive Into Catalyst: Apache Spark 2.0’s OptimizerDatabricks
 
Introducing Arc: A Common Intermediate Language for Unified Batch and Stream...
Introducing Arc:  A Common Intermediate Language for Unified Batch and Stream...Introducing Arc:  A Common Intermediate Language for Unified Batch and Stream...
Introducing Arc: A Common Intermediate Language for Unified Batch and Stream...Flink Forward
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithmsiqbalphy1
 
Flink 0.10 @ Bay Area Meetup (October 2015)
Flink 0.10 @ Bay Area Meetup (October 2015)Flink 0.10 @ Bay Area Meetup (October 2015)
Flink 0.10 @ Bay Area Meetup (October 2015)Stephan Ewen
 
Generalized Linear Models in Spark MLlib and SparkR
Generalized Linear Models in Spark MLlib and SparkRGeneralized Linear Models in Spark MLlib and SparkR
Generalized Linear Models in Spark MLlib and SparkRDatabricks
 
HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?bzamecnik
 
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...Data Con LA
 
Apache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapApache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapKostas Tzoumas
 
stacks and queues for public
stacks and queues for publicstacks and queues for public
stacks and queues for publiciqbalphy1
 
Extending Spark for Qbeast's SQL Data Source​ with Paola Pardo and Cesare Cug...
Extending Spark for Qbeast's SQL Data Source​ with Paola Pardo and Cesare Cug...Extending Spark for Qbeast's SQL Data Source​ with Paola Pardo and Cesare Cug...
Extending Spark for Qbeast's SQL Data Source​ with Paola Pardo and Cesare Cug...Qbeast
 
Apache Flink & Graph Processing
Apache Flink & Graph ProcessingApache Flink & Graph Processing
Apache Flink & Graph ProcessingVasia Kalavri
 
Apache Flink Training: System Overview
Apache Flink Training: System OverviewApache Flink Training: System Overview
Apache Flink Training: System OverviewFlink Forward
 
2015-06-15 Large-Scale Elastic-Net Regularized Generalized Linear Models at S...
2015-06-15 Large-Scale Elastic-Net Regularized Generalized Linear Models at S...2015-06-15 Large-Scale Elastic-Net Regularized Generalized Linear Models at S...
2015-06-15 Large-Scale Elastic-Net Regularized Generalized Linear Models at S...DB Tsai
 

What's hot (20)

Machine Learning with Apache Flink at Stockholm Machine Learning Group
Machine Learning with Apache Flink at Stockholm Machine Learning GroupMachine Learning with Apache Flink at Stockholm Machine Learning Group
Machine Learning with Apache Flink at Stockholm Machine Learning Group
 
Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and Iterations
 
Parallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowParallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflow
 
Unified Stream & Batch Processing with Apache Flink (Hadoop Summit Dublin 2016)
Unified Stream & Batch Processing with Apache Flink (Hadoop Summit Dublin 2016)Unified Stream & Batch Processing with Apache Flink (Hadoop Summit Dublin 2016)
Unified Stream & Batch Processing with Apache Flink (Hadoop Summit Dublin 2016)
 
Flink Gelly - Karlsruhe - June 2015
Flink Gelly - Karlsruhe - June 2015Flink Gelly - Karlsruhe - June 2015
Flink Gelly - Karlsruhe - June 2015
 
Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...
Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...
Apache Flink Internals: Stream & Batch Processing in One System – Apache Flin...
 
Predictive Datacenter Analytics with Strymon
Predictive Datacenter Analytics with StrymonPredictive Datacenter Analytics with Strymon
Predictive Datacenter Analytics with Strymon
 
Deep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
Deep Dive Into Catalyst: Apache Spark 2.0’s OptimizerDeep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
Deep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
 
Introducing Arc: A Common Intermediate Language for Unified Batch and Stream...
Introducing Arc:  A Common Intermediate Language for Unified Batch and Stream...Introducing Arc:  A Common Intermediate Language for Unified Batch and Stream...
Introducing Arc: A Common Intermediate Language for Unified Batch and Stream...
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Flink 0.10 @ Bay Area Meetup (October 2015)
Flink 0.10 @ Bay Area Meetup (October 2015)Flink 0.10 @ Bay Area Meetup (October 2015)
Flink 0.10 @ Bay Area Meetup (October 2015)
 
Generalized Linear Models in Spark MLlib and SparkR
Generalized Linear Models in Spark MLlib and SparkRGeneralized Linear Models in Spark MLlib and SparkR
Generalized Linear Models in Spark MLlib and SparkR
 
HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?HyperLogLog in Hive - How to count sheep efficiently?
HyperLogLog in Hive - How to count sheep efficiently?
 
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
Big Data Day LA 2015 - Large Scale Distinct Count -- The HyperLogLog algorith...
 
Apache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapApache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmap
 
stacks and queues for public
stacks and queues for publicstacks and queues for public
stacks and queues for public
 
Extending Spark for Qbeast's SQL Data Source​ with Paola Pardo and Cesare Cug...
Extending Spark for Qbeast's SQL Data Source​ with Paola Pardo and Cesare Cug...Extending Spark for Qbeast's SQL Data Source​ with Paola Pardo and Cesare Cug...
Extending Spark for Qbeast's SQL Data Source​ with Paola Pardo and Cesare Cug...
 
Apache Flink & Graph Processing
Apache Flink & Graph ProcessingApache Flink & Graph Processing
Apache Flink & Graph Processing
 
Apache Flink Training: System Overview
Apache Flink Training: System OverviewApache Flink Training: System Overview
Apache Flink Training: System Overview
 
2015-06-15 Large-Scale Elastic-Net Regularized Generalized Linear Models at S...
2015-06-15 Large-Scale Elastic-Net Regularized Generalized Linear Models at S...2015-06-15 Large-Scale Elastic-Net Regularized Generalized Linear Models at S...
2015-06-15 Large-Scale Elastic-Net Regularized Generalized Linear Models at S...
 

Similar to Parallel First-Order Operations

Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningPiotr Tylenda
 
Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningAgnieszka Potulska
 
CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)Ortus Solutions, Corp
 
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...Ortus Solutions, Corp
 
Spark Summit EU talk by Herman van Hovell
Spark Summit EU talk by Herman van HovellSpark Summit EU talk by Herman van Hovell
Spark Summit EU talk by Herman van HovellSpark Summit
 
SparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDsSparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDsDatabricks
 
CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...
CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...
CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...Obeo
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel ProcessingRTigger
 
Towards Parallel and Lazy Model Queries
Towards Parallel and Lazy Model QueriesTowards Parallel and Lazy Model Queries
Towards Parallel and Lazy Model QueriesSina Madani
 
Introduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaIntroduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaopenseesdays
 
Making fitting in RooFit faster
Making fitting in RooFit fasterMaking fitting in RooFit faster
Making fitting in RooFit fasterPatrick Bos
 
Performance van Java 8 en verder - Jeroen Borgers
Performance van Java 8 en verder - Jeroen BorgersPerformance van Java 8 en verder - Jeroen Borgers
Performance van Java 8 en verder - Jeroen BorgersNLJUG
 
Stream processing from single node to a cluster
Stream processing from single node to a clusterStream processing from single node to a cluster
Stream processing from single node to a clusterGal Marder
 
Scaling up genomic analysis with ADAM
Scaling up genomic analysis with ADAMScaling up genomic analysis with ADAM
Scaling up genomic analysis with ADAMfnothaft
 
Partitioning SKA Dataflows for Optimal Graph Execution
Partitioning SKA Dataflows for Optimal Graph ExecutionPartitioning SKA Dataflows for Optimal Graph Execution
Partitioning SKA Dataflows for Optimal Graph Execution Chen Wu
 
Workflow Allocations and Scheduling on IaaS Platforms, from Theory to Practice
Workflow Allocations and Scheduling on IaaS Platforms, from Theory to PracticeWorkflow Allocations and Scheduling on IaaS Platforms, from Theory to Practice
Workflow Allocations and Scheduling on IaaS Platforms, from Theory to PracticeFrederic Desprez
 

Similar to Parallel First-Order Operations (20)

Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine Learning
 
Log Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine LearningLog Analytics in Datacenter with Apache Spark and Machine Learning
Log Analytics in Datacenter with Apache Spark and Machine Learning
 
Google cloud Dataflow & Apache Flink
Google cloud Dataflow & Apache FlinkGoogle cloud Dataflow & Apache Flink
Google cloud Dataflow & Apache Flink
 
CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)
 
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...
 
Spark Summit EU talk by Herman van Hovell
Spark Summit EU talk by Herman van HovellSpark Summit EU talk by Herman van Hovell
Spark Summit EU talk by Herman van Hovell
 
SparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDsSparkSQL: A Compiler from Queries to RDDs
SparkSQL: A Compiler from Queries to RDDs
 
Streams in Java 8
Streams in Java 8Streams in Java 8
Streams in Java 8
 
CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...
CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...
CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel Processing
 
Towards Parallel and Lazy Model Queries
Towards Parallel and Lazy Model QueriesTowards Parallel and Lazy Model Queries
Towards Parallel and Lazy Model Queries
 
Introduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaIntroduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKenna
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
TiReX: Tiled Regular eXpression matching architecture
TiReX: Tiled Regular eXpression matching architectureTiReX: Tiled Regular eXpression matching architecture
TiReX: Tiled Regular eXpression matching architecture
 
Making fitting in RooFit faster
Making fitting in RooFit fasterMaking fitting in RooFit faster
Making fitting in RooFit faster
 
Performance van Java 8 en verder - Jeroen Borgers
Performance van Java 8 en verder - Jeroen BorgersPerformance van Java 8 en verder - Jeroen Borgers
Performance van Java 8 en verder - Jeroen Borgers
 
Stream processing from single node to a cluster
Stream processing from single node to a clusterStream processing from single node to a cluster
Stream processing from single node to a cluster
 
Scaling up genomic analysis with ADAM
Scaling up genomic analysis with ADAMScaling up genomic analysis with ADAM
Scaling up genomic analysis with ADAM
 
Partitioning SKA Dataflows for Optimal Graph Execution
Partitioning SKA Dataflows for Optimal Graph ExecutionPartitioning SKA Dataflows for Optimal Graph Execution
Partitioning SKA Dataflows for Optimal Graph Execution
 
Workflow Allocations and Scheduling on IaaS Platforms, from Theory to Practice
Workflow Allocations and Scheduling on IaaS Platforms, from Theory to PracticeWorkflow Allocations and Scheduling on IaaS Platforms, from Theory to Practice
Workflow Allocations and Scheduling on IaaS Platforms, from Theory to Practice
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

Parallel First-Order Operations

  • 1. Parallel first-order operations Sina Madani, Dimitris Kolovos, Richard Paige {sm1748, dimitris.kolovos, richard.paige}@york.ac.uk Enterprise Systems, Department of Computer Science 1OCL 2018, Copenhagen
  • 2. Outline • Background and related work • Epsilon Object Language (EOL) • Parallelisation challenges and solutions • Performance evaluation • Future work • Questions 2OCL 2018, Copenhagen
  • 3. Motivation • Scalability is an active research area in model-driven engineering • Collaboration and versioning • Persistence and distribution • Continuous event processing • Queries and transformations • Very large models / datasets common in complex industrial projects • First-order operations frequently used in model management tasks • Diminishing single-thread performance, increasing number of cores • Vast majority of operations on collections are pure functions • i.e. inherently thread-safe and parallelisable 3OCL 2018, Copenhagen
  • 4. Related Work • Parallel ATL (Tisi et al., 2013) • Task-parallel approach to model transformation • Parallel OCL (Vajk et al., 2011) • Automated parallel code generation based on CSP and C# • Lazy OCL (Tisi et al., 2015) • Iterator-based lazy evaluation of expressions on collections • Parallel Streams (Java 8+, 2013) • Rich and powerful API for general queries and transformations • Combines lazy semantics with divide-and-conquer parallelism 4OCL 2018, Copenhagen
  • 5. Epsilon Object Language (EOL) • Powerful imperative programming constructs • Independent of underlying modelling technology • Interpreted, model-oriented Java + OCL-like language • Base query language of Epsilon • Global variables • Cached operations • ...and more 5OCL 2018, Copenhagen
  • 6. General challenges / assumptions • Need to capture state prior to parallel execution • e.g. Any declared variables need to be accessible • Side-effects need not be persisted • e.g. through operation invocations • Operations should not depend on mutable global state • Caches need to be thread-safe • Through synchronization or atomicity • Mutable engine internals (e.g. frame stack) are thread-local • Intermediate variables’ scope is limited to each parallel “job” • No nested parallelism 6OCL 2018, Copenhagen
  • 7. Collection<T> select (Expression<Boolean> predicate, Collection<T> source) • Filters the collection based on a predicate applied to each element var jobs = new ArrayList<Callable<Optional<T>>>(source.size()); for (T element : source) { jobs.add(() -> { if (predicate.execute(element)) return Optional.of(element); else return Optional.empty(); }); } context.executeParallel(jobs).forEach(opt -> opt.ifPresent(results::add)); return results; OCL 2018, Copenhagen 7
  • 8. context.executeParallel (ordered) EolThreadPoolExecutor executorService = getExecutorService(); List<Future<T>> futureResults = jobs.stream() .map(executorService::submit).collect(Collectors.toList()); List<T> actualResults = new ArrayList<>(futureResults.size()); for (Future<T> future : futureResults) { actualResults.add(future.get()); } return actualResults; OCL 2018, Copenhagen 8
  • 9. T selectOne (Expression<Boolean> predicate, Collection<T> source) • Finds any* element matching the predicate • Same as select, except with short-circuiting for (T element : source) { jobs.add(() -> { if (predicate.execute(element)) context.completeShortCircuit(Optional.of(element)); }); } Optional<T> result = context.awaitShortCircuit(jobs); hasResult = result != null; if (hasResult) return result.get(); OCL 2018, Copenhagen 9
  • 10. context.shortCircuit • ExecutionStatus object used for signalling completion • “AwaitCompletion” thread waits for completion of jobs • Also checks whether the completion status has been signalled • Main thread waits for the ExecutionStatus to be signalled • Call to context.completeShortCircuit() signals the ExecutionStatus • “AwaitCompletion” terminates upon interruption • After control returns to main thread, remaining jobs are cancelled OCL 2018, Copenhagen 10
  • 11. Boolean nMatch (Expression<Boolean> predicate, int n, Collection<T> source) • Returns true iff the collection contains exactly n elements satisfying the predicate AtomicInteger matches = new AtomicInteger(), evaluated = new AtomicInteger(); for (T element : source) { jobs.add(() -> { int evaluatedInt = evaluated.incrementAndGet(); if (predicate.execute(element) && (matches.incrementAndGet() > n || sourceSize – evaluatedInt < n - matches.get())) { context.completeShortCircuit(); } }); } return matches.get() == n; OCL 2018, Copenhagen 11
  • 12. Boolean exists (Expression<Boolean> predicate, Collection<T> source) • Returns true if any element matches the predicate • Same as selectOne, but returns a Boolean var selectOne = new ParallelSelectOneOperation(); selectOne.execute(source, predicateExpression); return selectOne.hasResult(); OCL 2018, Copenhagen 12
  • 13. Boolean forAll (Expression<Boolean> predicate, Collection<T> source) • Returns true iff all elements match the predicate • Delegate to nMatch to benefit from short-circuiting var nMatch = new ParallelNMatchOperation(source.size()); return nMatch.execute(source, predicateExpression); • Alternatively, delegate to exists with inverted predicate OCL 2018, Copenhagen 13
  • 14. Collection<R> collect (Expression<R> mapFunction, Collection<T> source) • Transforms each element T into R, returning the result collection • Computationally similar to select, but simpler • No wrapper required, since we’re performing a one-to-one mapping var jobs = new ArrayList<Callable<R>>(source.size()); for (T element : source) { jobs.add(() -> mapFunction.execute(element)); } context.executeParallel(jobs).forEach(results::add); return results; OCL 2018, Copenhagen 14
  • 15. List<T> sortBy (Expression<Comparable<?>> property, Collection<T> source) • Sorts the collection according to the derived Comparable • Maps each element to a Comparable using collect • Sorts the derived collection based on the Comparator property of each derived element • Sorting can be parallelised using java.util.Arrays.parallelSort • Divide-and-conquer approach, sequential threshold = 8192 elements OCL 2018, Copenhagen 15
  • 16. Map<K, Collection<T>> mapBy (Expression<K> keyExpr, Collection<T> source) • Groups elements based on the derived key expression var jobs = new ArrayList<Callable<Map.Entry<K, T>>>(source.size()); for (T element : source) { jobs.add(() -> { K result = keyExpr.execute(element); return new SimpleEntry<>(result, element); }); } Collection<Map.Entry<K, T>> intermediates = context.executeParallel(jobs); Map<K, Sequence<T>> result = mergeByKey(intermediates); return result; OCL 2018, Copenhagen 16
  • 17. Testing for correctness • EUnit – JUnit-style tests for Epsilon • Testing of all operations, with corner cases • Equivalence test of sequential and parallel operations • Testing of scope capture, operation calls, exception handling etc. • Repeated many times with no failures OCL 2018, Copenhagen 17
  • 19. Performance evaluation 19 • Execution time on X axis • Speedup indicated on data points (higher is better) • Number of threads indicated in parentheses on Y axis • All tests performed on following system: • AMD Threadripper 1950X (16 core / 32 threads) • 32 GB (4 x 8GB) DDR4-3000MHz RAM • Oracle JDK 11 HotSpot VM • Fedora 28 OS OCL 2018, Copenhagen
  • 20. 20OCL 2018, Copenhagen 1 12.438 13.334 0 1000 2000 3000 4000 5000 6000 7000 8000 9000 Sequential Parallel (16) Parallel (32) Execution time (seconds) select (3.53 million elements)
  • 23. Future Work • closure • aggregate and iterate • Identify bottlenecks to improve performance • Combine with lazy solution • More comprehensive performance evaluation • Test all operations • Compare with Eclipse OCL • More varied and complex models / queries 23OCL 2018, Copenhagen
  • 24. Questions? 24 sm1748@york.ac.uk OCL 2018, Copenhagen eclipse.org/epsilon • Data-parallelisation of first-order operations on collections • Short-circuiting operations more complex to deal with • Stateful operations, such as mapBy, require different approach • Significant performance improvement with more cores • Open-source github.com/epsilonlabs/parallel-erl
  • 25. Thread-local base delegation example • Can be used to solve variable scoping • Each thread has its own frame stack (used for storing variables) • Each thread-local frame stack has a reference to the main thread’s frame stack • If a variable in the thread-local frame stack can’t be found, look in the main thread frame stack • Main thread frame stack should be thread-safe, but thread-local frame stacks needn’t be 25OCL 2018, Copenhagen
  • 26. Control Flow Traceability • Different parts of the program could be executing simultaneously • Need execution trace for all threads • Solution: • Each thread has its own execution controller • Record the trace when exception occurs • Parallel execution terminates when any thread encounters an exception 26OCL 2018, Copenhagen

Editor's Notes

  1. Spend no more than 30 seconds here
  2. Performance issues arise with very large models. Lazy evaluation can be performed on collections using iterators, which improves performance when chaining operations.
  3. EVL is a hybrid language. It provides declarative structure like OCL but has general-purpose programming constructs.
  4. Lazy initialisation of data structures like caches can also be a problem. Similarities to “Effectively final” concept in Java lambdas and streams
  5. Note the List: ordering is guaranteed because jobs are submitted sequentially (and queries sequentially)
  6. *Any = not necessarily first
  7. Short-circuit if not enough or too many matches
  8. No new/explicitly parallel implementation needed
  9. mergeByKey code uses Collectors API (omitted for brevity, but should be obvious what the idea is)
  10. SMT only improving performance by +1x Approximately 2+ hours down to about 10 minutes!
  11. SMT only improving performance by +1x