SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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...
 

Semelhante a 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
 

Semelhante a 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
 

Último

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 

Último (20)

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 

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

Notas do Editor

  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