SlideShare a Scribd company logo
1 of 22
Download to read offline
Sequence: Pipeline modelling in Pharo
IWST 2023: International Workshop on Smalltalk Technologies,
August 29-31, 2023, Lyon, France
Dmitry Matveev
Intel Corporation
August 31, 2023
Outline
Introduction
Sequence overview
Implementation
Future
The background
What we did
▶ We developed platforms: SoC for IoT.
▶ Platforms bring various capabilities, e.g:
▶ Camera (MIPI), Media (codec), AI, DSP, etc.
▶ Capabilities are utilized by workloads.
▶ Workloads enable use-cases and their KPIs:
▶ "Handle N streams at K FPS while doing X".
The environemnt
How we did it
▶ Every component had its own team:
▶ Development, testing, benchmarking done individually;
▶ The integration team pulled all components together to make
a BKC:
▶ "Best-Known Conguration.
Pre-production hardware is fun
▶ A very limited number of units.
▶ May be not very stable in the beginning.
The problem
How to evaluate the system performance without having the
complete system ready?
▶ Simulate it!
Why it matters?
▶ Understand how every individual component contributes to the
overall performance:
▶ What (where) to optimize next?
▶ Understand the application ow:
▶ Are there execution gaps or stalls?
▶ How to reorganize the application ow to meet the criteria?
Seeking for a solution
Simulator expectations
▶ Allow to describe system resources;
▶ Allow to dene building blocks using that resources;
▶ Allow to build scenarios atop of these blocks;
▶ Collect information of interest;
▶ Present the interactive system trace for inspection;
▶ Provide rapid feedback for what-if? and trial-and-error
analysis.
Crafting the solution
Why Smalltalk
▶ There was no good out-of-the box solution;
▶ Pharo itself was closest to become a solution:
▶ Smalltalk is a nice language to describe things;
▶ Pharo Playground (Ctrl+G) is all we need for rapid feedback;
▶ Roassal is a nice visualization framework.
▶ Only a simulator engine itself was missing.
Sequence: A minimum example
| a b |
a := 'A' asSeqBlock latency: 20 ms.
b := 'B' asSeqBlock latency: 20 fps.
a  b.
(Sequence startingWith: a)
runFor: 500 m
Sequence: Data stream example
| s w g |
s := 'S' asSeqBlock latency: [ :f | (f data * 10) ms ].
w := 'W' asSeqBlock latency: 25 ms.
s  w.
g := PMPoissonGenerator new lambda: 5.
(Sequence startingWith: s)
runFor: 800 ms
on: [ g next ]
Sequence: Resource sharing example
| a b t |
t := SeqTarget new lanes: 2.
a := 'A' asSeqBlock latency: 25 ms; target: t; lanes: 2.
b := 'B' asSeqBlock latency: 30 ms; target: t; lanes: 1.
SeqNaiveMultiExecutor new
add: (Sequence startingWith: a);
add: (Sequence startingWith: b);
scheduler: SeqRoundRobinScheduler new;
runFor: 500 ms;
trace.
Sequence: Real-time processing example
| s1 a s2 b |
s1 := 'Src1' asSeqBlock latency: 30 fps; live.
a := 'A' asSeqBlock latency: 22 fps.
s2 := 'Src2' asSeqBlock latency: 30 fps; live.
b := 'B' asSeqBlock latency: 30 fps.
s1  a.
s2  b.
SeqNaiveMultiExecutor new
add: (Sequence startingWith: s1);
add: (Sequence startingWith: s2);
runFor: 500 ms;
trace.
Sequence: Advanced examples
Pipelining
| src a b c seq opts |
src := 'Src' asSeqBlock
latency: 30 fps;
live.
a := 'A' asSeqBlock latency: 33 ms.
b := 'B' asSeqBlock latency: 33 ms.
c := 'C' asSeqBlock latency: 33 ms.
src  a  b  c.
seq := Sequence startingWith: src.
opts := SeqExecOptions new
usePipelining;
dropFrames.
(SeqNaiveMultiExecutor new
scheduler: SeqRoundRobinScheduler new;
add: seq options: opts;
runFor: 500 ms;
trace) showFrameDrops; colorByFrames
Streams
| src a b c xpu seq opts |
src := 'Src' asSeqBlock
latency: 33 ms;
live.
a := 'A' asSeqBlock latency: 10 ms.
b := 'B' asSeqBlock latency: 45 ms.
c := 'C' asSeqBlock latency: 10 ms.
src  a  b  c.
xpu := SeqTarget new lanes: 2.
b target: xpu; streams: 2.
seq := Sequence startingWith: src.
opts := SeqExecOptions new
usePipelining;
dropFrames.
(SeqNaiveMultiExecutor new
scheduler: SeqRoundRobinScheduler new;
add: seq options: opts;
runFor: 500 ms;
trace) showFrameDrops; colorByFrames.
Sequence: Advanced examples
Pipelining example
Streams example
Sequence: Characteristics of a DES
Sequence is as Discrete Event Simulation (DES) system
▶ It registers Events that happen during the simulation;
▶ Events are essentially facts that particular blocks could execute;
▶ System state is dened by Targets which are free or locked at
the given time point;
▶ Targets are essentially the Resources;
▶ Simulation time is discrete, the current time pointer is
advanced by the coming events.
More on DES
▶ J. Banks, Introduction to Simulation (1999)
Sequence inside
▶ The core of Sequence is a simulation executor.
▶ There may be multiple but SeqNaiveMultiExecutor is the
most advanced at the time.
▶ Simulation executor represents sequences as running processes.
▶ Processes are running periodically with no termination criteria.
▶ The system-level termination criteria is simulation time
(#runFor:).
▶ Normally, a sequence object maps to a single execution
process, but there are exceptions:
▶ Sequences with live sources map to two processes, one for a
source block and one for the sequence;
▶ Pipelined sequences map to N interconnected processes: every
block gets its own process (or K processes if streams: k
property is assigned).
Sequence inside: Event streams
SeqEventStream: the heart of the simulation system
▶ Represents a running periodic process.
▶ FSM inside, handles one block (one target) at time.
▶ Provides compact API for the executor to manage:
▶ #canWork: answer executor if this particular stream can do the
work, depending on its state.
▶ #updateFrame:: sent implicitly within executor when stream's
input data is available (a new input frame is generated).
Stream updates its internal block stream based on this data.
▶ #advance: make next step (progress) in the process.
Internally, either lock or release the current resource for the
current block.
▶ #nextTick: answer the time of the next event in this stream.
▶ #updateTimePoint:: let the event stream know what is the
simulation time right now.
Sequence inside: Event stream state machine
#idle #ready #exec
Meaning No data available Data is available Data is available
Not entered execution yet Executing (may be blocked
waiting for a resource)
#canWork Asks canStartBlock This/next block can lock Lock acquired: true
its target No lock:
- See #canWork @ #ready
#advance Call startBlock Call startBlock if not yet Lock acquired: leave block
Move to #ready Enter a new block: - Release resource
- See #advance @ #exec - Record event
. . . If at the last block:
- Record completion
- Move to #idle
No lock:
- Peek next block
- Acquire a new lock
# i d l e
# r e a d y
# c a n S t a r t ?
# u p d a t e F r a m e :
# e x e c
# a d v a n c e
# a d v a n c e
(EOS)
# a d v a n c e
Sequence inside: Simulation executor loop
Simulation executor loop becomes straightforward with the
SeqEventStream abstraction dened above:
▶ Update time point for all streams;
▶ Ask which streams can work;
▶ Filter out streams which can work right now (time point is not
in the future);
▶ Let Scheduler decide which stream will be advanced;
▶ Advance the selected stream (#advance:) and update the
time point (sometimes with 0 increment).
▶ Repeat.
Note: advancing one stream invalidates invariants so some streams
which could work now may not work anymore in the next iteration.
Sequence inside: Scheduler
▶ User-congurable object (can implement your own);
▶ Integrated into:
▶ Executor loop: asked which stream to prefer if there're
multiple candidates to run right now.
▶ #decide: aCollectionOfStreams.
▶ Target (resource) locking: asked if a stream can lock this
resource.
▶ #askLockOn: aTarget for: aStream at: aSeqBlock:
targets consult with scheduler if an available resource can be
given on request;
▶ #waitlist: aStream to: aTarget: sent by a Stream to
inform it is interested in locking the target, if resource lock
request has been rejected.
▶ Available: SeqDumbScheduler, SeqRoundRobinScheduler,
SeqPriorityRRScheduler.
Next steps on Sequence
Short-term plan
▶ Extend test coverage, close the functionality gaps.
▶ Interoperability: export to Perfetto format.
▶ Prepare a formal release.
Mid-term plan
▶ Interoperability: import from Perfetto format.
▶ Introduce annotations: some way to mark parts of the
sequence we're especially interested in, to see it in the trace.
▶ Introduce monitors: custom hooks to probe and collect
simulation run-time information about the running processes
and resource state.
Sequence: Vision
Long-term vision
▶ Extend the time domain from milliseconds to arbitrary.
▶ Extend to model non-periodic processes.
▶ Consider Queues as the right abstraction to access targets?
▶ Composable simulations:
▶ What if a Sequence block is also simulation inside?
Thanks!
Sequence is already Open Source:
▶ Currently hosted at Github:
https://github.com/dmatveev/sequence.
▶ ~2.5KLOC of code, ~1.5KLOC of tests.
▶ MIT License.
Try it today!
Metacello new
baseline: 'Sequence';
repository: 'github://dmatveev/sequence';
load.

More Related Content

Similar to Sequence: Pipeline modelling in Pharo

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Swift profiling middleware and tools
Swift profiling middleware and toolsSwift profiling middleware and tools
Swift profiling middleware and toolszhang hua
 
Debugging node in prod
Debugging node in prodDebugging node in prod
Debugging node in prodYunong Xiao
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Sylvain Wallez
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak PROIDEA
 
Introduction to Chainer
Introduction to ChainerIntroduction to Chainer
Introduction to ChainerSeiya Tokui
 
HKG18-TR12 - LAVA for LITE Platforms and Tests
HKG18-TR12 - LAVA for LITE Platforms and TestsHKG18-TR12 - LAVA for LITE Platforms and Tests
HKG18-TR12 - LAVA for LITE Platforms and TestsLinaro
 
Scaling machine learning to millions of users with Apache Beam
Scaling machine learning to millions of users with Apache BeamScaling machine learning to millions of users with Apache Beam
Scaling machine learning to millions of users with Apache BeamTatiana Al-Chueyr
 
ACMSE2022-Tutorial-Slides.pptx
ACMSE2022-Tutorial-Slides.pptxACMSE2022-Tutorial-Slides.pptx
ACMSE2022-Tutorial-Slides.pptxSumit Roy
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPFAlex Maestretti
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of ChainerKenta Oono
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to TestZsolt Fabok
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with MicronautQAware GmbH
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with MicronautQAware GmbH
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practiceDocker, Inc.
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problemsTier1 app
 
VideoMR - A Map and Reduce Framework for Real-time Video Processing
VideoMR - A Map and Reduce Framework for Real-time Video ProcessingVideoMR - A Map and Reduce Framework for Real-time Video Processing
VideoMR - A Map and Reduce Framework for Real-time Video ProcessingMatthias Trapp
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Alessandro Molina
 

Similar to Sequence: Pipeline modelling in Pharo (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Ad Server Optimization
Ad Server OptimizationAd Server Optimization
Ad Server Optimization
 
Swift profiling middleware and tools
Swift profiling middleware and toolsSwift profiling middleware and tools
Swift profiling middleware and tools
 
Debugging node in prod
Debugging node in prodDebugging node in prod
Debugging node in prod
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
Introduction to Chainer
Introduction to ChainerIntroduction to Chainer
Introduction to Chainer
 
HKG18-TR12 - LAVA for LITE Platforms and Tests
HKG18-TR12 - LAVA for LITE Platforms and TestsHKG18-TR12 - LAVA for LITE Platforms and Tests
HKG18-TR12 - LAVA for LITE Platforms and Tests
 
Scaling machine learning to millions of users with Apache Beam
Scaling machine learning to millions of users with Apache BeamScaling machine learning to millions of users with Apache Beam
Scaling machine learning to millions of users with Apache Beam
 
ACMSE2022-Tutorial-Slides.pptx
ACMSE2022-Tutorial-Slides.pptxACMSE2022-Tutorial-Slides.pptx
ACMSE2022-Tutorial-Slides.pptx
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
 
Nexmark with beam
Nexmark with beamNexmark with beam
Nexmark with beam
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of Chainer
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practice
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problems
 
VideoMR - A Map and Reduce Framework for Real-time Video Processing
VideoMR - A Map and Reduce Framework for Real-time Video ProcessingVideoMR - A Map and Reduce Framework for Real-time Video Processing
VideoMR - A Map and Reduce Framework for Real-time Video Processing
 
Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2Reactive & Realtime Web Applications with TurboGears2
Reactive & Realtime Web Applications with TurboGears2
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 
BioSmalltalk
BioSmalltalkBioSmalltalk
BioSmalltalkESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 
BioSmalltalk
BioSmalltalkBioSmalltalk
BioSmalltalk
 

Recently uploaded

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 

Recently uploaded (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 

Sequence: Pipeline modelling in Pharo

  • 1. Sequence: Pipeline modelling in Pharo IWST 2023: International Workshop on Smalltalk Technologies, August 29-31, 2023, Lyon, France Dmitry Matveev Intel Corporation August 31, 2023
  • 3. The background What we did ▶ We developed platforms: SoC for IoT. ▶ Platforms bring various capabilities, e.g: ▶ Camera (MIPI), Media (codec), AI, DSP, etc. ▶ Capabilities are utilized by workloads. ▶ Workloads enable use-cases and their KPIs: ▶ "Handle N streams at K FPS while doing X".
  • 4. The environemnt How we did it ▶ Every component had its own team: ▶ Development, testing, benchmarking done individually; ▶ The integration team pulled all components together to make a BKC: ▶ "Best-Known Conguration. Pre-production hardware is fun ▶ A very limited number of units. ▶ May be not very stable in the beginning.
  • 5. The problem How to evaluate the system performance without having the complete system ready? ▶ Simulate it! Why it matters? ▶ Understand how every individual component contributes to the overall performance: ▶ What (where) to optimize next? ▶ Understand the application ow: ▶ Are there execution gaps or stalls? ▶ How to reorganize the application ow to meet the criteria?
  • 6. Seeking for a solution Simulator expectations ▶ Allow to describe system resources; ▶ Allow to dene building blocks using that resources; ▶ Allow to build scenarios atop of these blocks; ▶ Collect information of interest; ▶ Present the interactive system trace for inspection; ▶ Provide rapid feedback for what-if? and trial-and-error analysis.
  • 7. Crafting the solution Why Smalltalk ▶ There was no good out-of-the box solution; ▶ Pharo itself was closest to become a solution: ▶ Smalltalk is a nice language to describe things; ▶ Pharo Playground (Ctrl+G) is all we need for rapid feedback; ▶ Roassal is a nice visualization framework. ▶ Only a simulator engine itself was missing.
  • 8. Sequence: A minimum example | a b | a := 'A' asSeqBlock latency: 20 ms. b := 'B' asSeqBlock latency: 20 fps. a b. (Sequence startingWith: a) runFor: 500 m
  • 9. Sequence: Data stream example | s w g | s := 'S' asSeqBlock latency: [ :f | (f data * 10) ms ]. w := 'W' asSeqBlock latency: 25 ms. s w. g := PMPoissonGenerator new lambda: 5. (Sequence startingWith: s) runFor: 800 ms on: [ g next ]
  • 10. Sequence: Resource sharing example | a b t | t := SeqTarget new lanes: 2. a := 'A' asSeqBlock latency: 25 ms; target: t; lanes: 2. b := 'B' asSeqBlock latency: 30 ms; target: t; lanes: 1. SeqNaiveMultiExecutor new add: (Sequence startingWith: a); add: (Sequence startingWith: b); scheduler: SeqRoundRobinScheduler new; runFor: 500 ms; trace.
  • 11. Sequence: Real-time processing example | s1 a s2 b | s1 := 'Src1' asSeqBlock latency: 30 fps; live. a := 'A' asSeqBlock latency: 22 fps. s2 := 'Src2' asSeqBlock latency: 30 fps; live. b := 'B' asSeqBlock latency: 30 fps. s1 a. s2 b. SeqNaiveMultiExecutor new add: (Sequence startingWith: s1); add: (Sequence startingWith: s2); runFor: 500 ms; trace.
  • 12. Sequence: Advanced examples Pipelining | src a b c seq opts | src := 'Src' asSeqBlock latency: 30 fps; live. a := 'A' asSeqBlock latency: 33 ms. b := 'B' asSeqBlock latency: 33 ms. c := 'C' asSeqBlock latency: 33 ms. src a b c. seq := Sequence startingWith: src. opts := SeqExecOptions new usePipelining; dropFrames. (SeqNaiveMultiExecutor new scheduler: SeqRoundRobinScheduler new; add: seq options: opts; runFor: 500 ms; trace) showFrameDrops; colorByFrames Streams | src a b c xpu seq opts | src := 'Src' asSeqBlock latency: 33 ms; live. a := 'A' asSeqBlock latency: 10 ms. b := 'B' asSeqBlock latency: 45 ms. c := 'C' asSeqBlock latency: 10 ms. src a b c. xpu := SeqTarget new lanes: 2. b target: xpu; streams: 2. seq := Sequence startingWith: src. opts := SeqExecOptions new usePipelining; dropFrames. (SeqNaiveMultiExecutor new scheduler: SeqRoundRobinScheduler new; add: seq options: opts; runFor: 500 ms; trace) showFrameDrops; colorByFrames.
  • 13. Sequence: Advanced examples Pipelining example Streams example
  • 14. Sequence: Characteristics of a DES Sequence is as Discrete Event Simulation (DES) system ▶ It registers Events that happen during the simulation; ▶ Events are essentially facts that particular blocks could execute; ▶ System state is dened by Targets which are free or locked at the given time point; ▶ Targets are essentially the Resources; ▶ Simulation time is discrete, the current time pointer is advanced by the coming events. More on DES ▶ J. Banks, Introduction to Simulation (1999)
  • 15. Sequence inside ▶ The core of Sequence is a simulation executor. ▶ There may be multiple but SeqNaiveMultiExecutor is the most advanced at the time. ▶ Simulation executor represents sequences as running processes. ▶ Processes are running periodically with no termination criteria. ▶ The system-level termination criteria is simulation time (#runFor:). ▶ Normally, a sequence object maps to a single execution process, but there are exceptions: ▶ Sequences with live sources map to two processes, one for a source block and one for the sequence; ▶ Pipelined sequences map to N interconnected processes: every block gets its own process (or K processes if streams: k property is assigned).
  • 16. Sequence inside: Event streams SeqEventStream: the heart of the simulation system ▶ Represents a running periodic process. ▶ FSM inside, handles one block (one target) at time. ▶ Provides compact API for the executor to manage: ▶ #canWork: answer executor if this particular stream can do the work, depending on its state. ▶ #updateFrame:: sent implicitly within executor when stream's input data is available (a new input frame is generated). Stream updates its internal block stream based on this data. ▶ #advance: make next step (progress) in the process. Internally, either lock or release the current resource for the current block. ▶ #nextTick: answer the time of the next event in this stream. ▶ #updateTimePoint:: let the event stream know what is the simulation time right now.
  • 17. Sequence inside: Event stream state machine #idle #ready #exec Meaning No data available Data is available Data is available Not entered execution yet Executing (may be blocked waiting for a resource) #canWork Asks canStartBlock This/next block can lock Lock acquired: true its target No lock: - See #canWork @ #ready #advance Call startBlock Call startBlock if not yet Lock acquired: leave block Move to #ready Enter a new block: - Release resource - See #advance @ #exec - Record event . . . If at the last block: - Record completion - Move to #idle No lock: - Peek next block - Acquire a new lock # i d l e # r e a d y # c a n S t a r t ? # u p d a t e F r a m e : # e x e c # a d v a n c e # a d v a n c e (EOS) # a d v a n c e
  • 18. Sequence inside: Simulation executor loop Simulation executor loop becomes straightforward with the SeqEventStream abstraction dened above: ▶ Update time point for all streams; ▶ Ask which streams can work; ▶ Filter out streams which can work right now (time point is not in the future); ▶ Let Scheduler decide which stream will be advanced; ▶ Advance the selected stream (#advance:) and update the time point (sometimes with 0 increment). ▶ Repeat. Note: advancing one stream invalidates invariants so some streams which could work now may not work anymore in the next iteration.
  • 19. Sequence inside: Scheduler ▶ User-congurable object (can implement your own); ▶ Integrated into: ▶ Executor loop: asked which stream to prefer if there're multiple candidates to run right now. ▶ #decide: aCollectionOfStreams. ▶ Target (resource) locking: asked if a stream can lock this resource. ▶ #askLockOn: aTarget for: aStream at: aSeqBlock: targets consult with scheduler if an available resource can be given on request; ▶ #waitlist: aStream to: aTarget: sent by a Stream to inform it is interested in locking the target, if resource lock request has been rejected. ▶ Available: SeqDumbScheduler, SeqRoundRobinScheduler, SeqPriorityRRScheduler.
  • 20. Next steps on Sequence Short-term plan ▶ Extend test coverage, close the functionality gaps. ▶ Interoperability: export to Perfetto format. ▶ Prepare a formal release. Mid-term plan ▶ Interoperability: import from Perfetto format. ▶ Introduce annotations: some way to mark parts of the sequence we're especially interested in, to see it in the trace. ▶ Introduce monitors: custom hooks to probe and collect simulation run-time information about the running processes and resource state.
  • 21. Sequence: Vision Long-term vision ▶ Extend the time domain from milliseconds to arbitrary. ▶ Extend to model non-periodic processes. ▶ Consider Queues as the right abstraction to access targets? ▶ Composable simulations: ▶ What if a Sequence block is also simulation inside?
  • 22. Thanks! Sequence is already Open Source: ▶ Currently hosted at Github: https://github.com/dmatveev/sequence. ▶ ~2.5KLOC of code, ~1.5KLOC of tests. ▶ MIT License. Try it today! Metacello new baseline: 'Sequence'; repository: 'github://dmatveev/sequence'; load.