360|Flex 2010: Greenthreading in Flex
Presented by Huyen Tue Dao
Maintaining application responsiveness and integrity by emulating threading for data- and computation-heavy code.
FreeRTOS basics (Real time Operating System)Naren Chandra
A presentation that covers all the basics needed to understand and start working with FreeRTOS . FreeRTOS is comparable with more than 20 controller families and 30 plus supporting tools and IDEs.
FreeRTOS is a market-leading real-time operating system (RTOS) for microcontrollers and small microprocessors. Distributed freely under the MIT open source license, FreeRTOS includes a kernel and a growing set of libraries suitable for use across all industry sectors. FreeRTOS is built with an emphasis on reliability and ease of use.
Tiny, power-saving kernel
Scalable size, with usable program memory footprint as low as 9KB. Some architectures include a tick-less power saving mode
Support for 40+ architectures
One code base for 40+ MCU architectures and 15+ toolchains, including the latest RISC-V and ARMv8-M (Arm Cortex-M33) microcontrollers
Modular libraries
A growing number of add-on libraries used across all industries sectors, including secure local or cloud connectivity
IoT Reference Integrations
Take advantage of tested examples that include all the libraries essential to securely connect to the cloud
A brief introduction to Process synchronization in Operating Systems with classical examples and solutions using semaphores. A good starting tutorial for beginners.
Join this video course on Udemy. Click the below link
https://www.udemy.com/mastering-rtos-hands-on-with-freertos-arduino-and-stm32fx/?couponCode=SLIDESHARE
>> The Complete FreeRTOS Course with Programming and Debugging <<
"The Biggest objective of this course is to demystifying RTOS practically using FreeRTOS and STM32 MCUs"
STEP-by-STEP guide to port/run FreeRTOS using development setup which includes,
1) Eclipse + STM32F4xx + FreeRTOS + SEGGER SystemView
2) FreeRTOS+Simulator (For windows)
Demystifying the complete Architecture (ARM Cortex M) related code of FreeRTOS which will massively help you to put this kernel on any target hardware of your choice.
FreeRTOS basics (Real time Operating System)Naren Chandra
A presentation that covers all the basics needed to understand and start working with FreeRTOS . FreeRTOS is comparable with more than 20 controller families and 30 plus supporting tools and IDEs.
FreeRTOS is a market-leading real-time operating system (RTOS) for microcontrollers and small microprocessors. Distributed freely under the MIT open source license, FreeRTOS includes a kernel and a growing set of libraries suitable for use across all industry sectors. FreeRTOS is built with an emphasis on reliability and ease of use.
Tiny, power-saving kernel
Scalable size, with usable program memory footprint as low as 9KB. Some architectures include a tick-less power saving mode
Support for 40+ architectures
One code base for 40+ MCU architectures and 15+ toolchains, including the latest RISC-V and ARMv8-M (Arm Cortex-M33) microcontrollers
Modular libraries
A growing number of add-on libraries used across all industries sectors, including secure local or cloud connectivity
IoT Reference Integrations
Take advantage of tested examples that include all the libraries essential to securely connect to the cloud
A brief introduction to Process synchronization in Operating Systems with classical examples and solutions using semaphores. A good starting tutorial for beginners.
Join this video course on Udemy. Click the below link
https://www.udemy.com/mastering-rtos-hands-on-with-freertos-arduino-and-stm32fx/?couponCode=SLIDESHARE
>> The Complete FreeRTOS Course with Programming and Debugging <<
"The Biggest objective of this course is to demystifying RTOS practically using FreeRTOS and STM32 MCUs"
STEP-by-STEP guide to port/run FreeRTOS using development setup which includes,
1) Eclipse + STM32F4xx + FreeRTOS + SEGGER SystemView
2) FreeRTOS+Simulator (For windows)
Demystifying the complete Architecture (ARM Cortex M) related code of FreeRTOS which will massively help you to put this kernel on any target hardware of your choice.
CPU Scheduling is the process through which we can find the best way to check the shortest and fastest working. Different Algorithms are explained here in this chapter. First-come-first-servers, Shortest Job First, Shortest remaining time first,
Round Robin, Priority Scheduler.
Deadlock is the problem that held in our data transition in our Operating System. As operating system is now very intelligent so it solve the problems automatically. Read it hope so you will like this Chapter. Best of Luck.
Thank you!
Join this video course on Udemy. Click the below link
https://www.udemy.com/mastering-rtos-hands-on-with-freertos-arduino-and-stm32fx/?couponCode=SLIDESHARE
>> The Complete FreeRTOS Course with Programming and Debugging <<
"The Biggest objective of this course is to demystifying RTOS practically using FreeRTOS and STM32 MCUs"
STEP-by-STEP guide to port/run FreeRTOS using development setup which includes,
1) Eclipse + STM32F4xx + FreeRTOS + SEGGER SystemView
2) FreeRTOS+Simulator (For windows)
Demystifying the complete Architecture (ARM Cortex M) related code of FreeRTOS which will massively help you to put this kernel on any target hardware of your choice.
https://www.learntek.org/blog/python-multithreading/
https://www.learntek.org/
Learntek is global online training provider on Big Data Analytics, Hadoop, Machine Learning, Deep Learning, IOT, AI, Cloud Technology, DEVOPS, Digital Marketing and other IT and Management courses.
https://www.learntek.org/blog/python-multithreading/
https://www.learntek.org/
Learntek is global online training provider on Big Data Analytics, Hadoop, Machine Learning, Deep Learning, IOT, AI, Cloud Technology, DEVOPS, Digital Marketing and other IT and Management courses.
Deep into your applications, performance & profilingFabien Arcellier
Presentation of profiling method based on instrumented and sampling profiler to the perfug at Paris the 17 september 2015
Code source is available on github : https://github.com/FabienArcellier/Perfug-Deep-into-your-application
CPU Scheduling is the process through which we can find the best way to check the shortest and fastest working. Different Algorithms are explained here in this chapter. First-come-first-servers, Shortest Job First, Shortest remaining time first,
Round Robin, Priority Scheduler.
Deadlock is the problem that held in our data transition in our Operating System. As operating system is now very intelligent so it solve the problems automatically. Read it hope so you will like this Chapter. Best of Luck.
Thank you!
Join this video course on Udemy. Click the below link
https://www.udemy.com/mastering-rtos-hands-on-with-freertos-arduino-and-stm32fx/?couponCode=SLIDESHARE
>> The Complete FreeRTOS Course with Programming and Debugging <<
"The Biggest objective of this course is to demystifying RTOS practically using FreeRTOS and STM32 MCUs"
STEP-by-STEP guide to port/run FreeRTOS using development setup which includes,
1) Eclipse + STM32F4xx + FreeRTOS + SEGGER SystemView
2) FreeRTOS+Simulator (For windows)
Demystifying the complete Architecture (ARM Cortex M) related code of FreeRTOS which will massively help you to put this kernel on any target hardware of your choice.
https://www.learntek.org/blog/python-multithreading/
https://www.learntek.org/
Learntek is global online training provider on Big Data Analytics, Hadoop, Machine Learning, Deep Learning, IOT, AI, Cloud Technology, DEVOPS, Digital Marketing and other IT and Management courses.
https://www.learntek.org/blog/python-multithreading/
https://www.learntek.org/
Learntek is global online training provider on Big Data Analytics, Hadoop, Machine Learning, Deep Learning, IOT, AI, Cloud Technology, DEVOPS, Digital Marketing and other IT and Management courses.
Deep into your applications, performance & profilingFabien Arcellier
Presentation of profiling method based on instrumented and sampling profiler to the perfug at Paris the 17 september 2015
Code source is available on github : https://github.com/FabienArcellier/Perfug-Deep-into-your-application
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)Patricia Aas
The Linux Security and Isolation APIs have become the basis of some of the most useful features server-side, providing the isolation required for efficient containers.
However, these APIs also form the basis of the Chromium Sandbox on Linux, and we will study them in that context. This is the sandbox used in the Vivaldi, Brave, Chrome and Opera browsers among others. The Chromium Sandbox has a very platform specific implementation, using the platform APIs available to construct it. In this talk we will describe the requirements of the Chromium Sandbox in detail and go through how the Linux implementation fulfills these requirements.
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Tim Bunce
Slides of my talk on Devel::NYTProf and optimizing perl code at the Italian Perl Workshop (IPW09). It covers the new features in NYTProf v3 and a new section outlining a multi-phase approach to optimizing your perl code.
30 mins long plus 10 mins of questions. Best viewed fullscreen.
My team heavily uses both Serverless and Terraform to build infrastructure, but as the number of projects we managed grew, it got harder to know how components were glued in different projects.
So we decided to try different ways to structure our projects in order
to :
– make better use terraform modules
– run terraform in a more secure manner
– share serverless components in a reliable way
– abstract complex infrastructure gluing
– faster project bootstrap times
Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/2msgBlb.
Kavya Joshi explores when and why locks affect performance, delves into Go’s lock implementation as a case study, and discusses strategies one can use when locks are actually a problem. Filmed at qconnewyork.com.
Kavya Joshi works as a software engineer at Samsara - a start-up in San Francisco. She particularly enjoys architecting and building highly concurrent, highly scalable systems.
The Beam Vision for Portability: "Write once run anywhere"Knoldus Inc.
This session is all about knowing a modern way to define and execute data processing pipelines with Apache Beam, an open-source unified programming model. we will talk about the Apache Beam vision and the benefits of the Beam Portability framework. The Beam Portability framework achieves the vision that a developer can use their favourite programming language with their preferred execution backend.
Developing a Reverberation Plugin with the aim of a Genetic AlgorithmLorenzo Monni
In this project we developed a Reverberation Plugin using the RackAFX API in C++. We experimented a genetic algorithm to approximate the impulse response of a real reverberation, using a the perceptual framework of Generalized Feedback Network.
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Tim Bunce
The slides of my "State-of-the-art Profiling with Devel::NYTProf" talk at OSCON in July 2009.
I'll upload a screencast and give the link in a blog post at http://blog.timbunce.org
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
GridMate - End to end testing is a critical piece to ensure quality and avoid...ThomasParaiso2
End to end testing is a critical piece to ensure quality and avoid regressions. In this session, we share our journey building an E2E testing pipeline for GridMate components (LWC and Aura) using Cypress, JSForce, FakerJS…
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
2. About me
Fell in love with
programming in a C++ class
in high school.
Flex developer since 2006.
Second time presenting,
first time at 360|Flex.
Weapons of choice in L4D2:
grenade launcher/katana
“…PATENTED APPROACH OF SHOOT FIRST, SHOOT LATER, I AM THE STIG…OKAY, NOT REALLY BUT I DID PASS MY
SHOOT SOME MORE AND THEN WHEN EVERYBODY'S DEAD DRIVER’S TEST ON THE FIRST GO
TRY TO ASK A QUESTION OR TWO.”
4. The Problem
Flash Player well suited to certain tasks: animation.
Seems to be able to do several things at once:
concurrency.
However, it can get hung up if one of these things
requires lots of processing.
Does not take complex code to hang it up either.
Let me show you…
GREENTHREADING IN FLEX
5. The Problem
The problem revolves around Flash platform’s
event-driven, frame-base architecture.
Flash movies/SWFs: content divided into frames
played according to a timeline.
GREENTHREADING IN FLEX
6. FLASH SWF
1 2 3 4 5 6
TIMELINE
FLEX SWF
1 2
FRAME 2 REPEATEDLY CALLED
TIMELINE
FRAME 1 FRAME 2
BOOTSTRAPPING/ APPLICATION CODE
PRELOADER
WHAT THE SWF KIND OF LOOKS LIKE
ARTIST (NOT-SO-MUCH) RENDERING
7. The Problem
Flash platform is event-driven: most everything is
triggered by an event.
Events collected into the Event Queue.
FP handles one event at time.
To get to the next frame? An event is triggered.
GREENTHREADING IN FLEX
8. 1 2 3 4 5 6
TIMELINE
EVENTS DISPATCHED IN FRAME 1
EVENT QUEUE
KEYBOARD EVENT MOUSE EVENTS
*FRAME EVENT
THE EVENT QUEUE
ARTIST (NOT-SO-MUCH) RENDERING
9. The Problem
SWF plays at a certain number of frames per second
(FPS). The time per frame is 1/FPS.
Default FPS is 24. Therefore, a frame needs to
execute every ~42 milliseconds.
Application FPS is not a minimum, it’s a maximum.
If code running in a frame takes longer than allotted
time, FP cannot process next frame event “on time.”
Hello, non-responsive window/beach ball of death.
GREENTHREADING IN FLEX
10. The Problem
Another way to look at it, using Ted Patrick’s Elastic Mental Racetrack:
IMAGE FROM SEAN CHRISTMANN’S UPDATED ‘ELASTIC RACETRACK’ FOR FLASH 9 AND AVM2
The racetrack extends to accommodate whatever code it is asked to execute.
No built-in way to defer execution till later.
If FP starts executing long-running code, code execution half will just keep
elongating.
FP gets stuck running on the first half of the track.
GREENTHREADING IN FLEX
11. Some Solutions
General idea: break up long-running code into
smaller batches/jobs.
Trigger batches at different times, different frames.
Gives FP a chance to catch up.
Allow other events to be processed (including the
important screen-updating events).
GREENTHREADING IN FLEX
12. Some Solutions
Several ways to break up the process:
callLater( ): function called using this will be queued and
run either at handler for RENDER event or at the next
ENTER_FRAME event
UIComponent method
“Some features, like effects, can cause queued
functions to be delayed until the feature completes…”
ENTER_FRAME: run a batch explicitly at each frame
Timers: run a batch every χ milliseconds
GREENTHREADING IN FLEX
13. Some Solutions
AND NOW FOR A LITTLE CODE…
// To break up an algorithm via callLater()
// 1. Write a method that performs the main work of algorithm and takes as
// parameters the current iteration and the total iterations to execute.
// 2. In method heck for stopping condition and if it has not been reached,
// use callLater to schedule a new call to method.
...
<!-- Some object that is being displayed -->
<mx:UIComponent id=”obj”/>
...
var numIterations : int = 0;
var totalIterations : int = 100000;
private function runLoop(... args) : void
{
// Do work of iteration here.
numIterations++;
if(numIterations < totalIterations)
{
obj.callLater( runLoop, /* args to pass to next method call */ );
}
}
GREENTHREADING IN FLEX
14. Some Solutions
AND NOW FOR A LITTLE CODE…
// To break up an algorithm via a ENTER_FRAME event.
// 1. Initialize progress variables.
// 2. Add a listener to the application for the ENTER_FRAME event the does
// main work of the algorithm.
// 3. In handler check for stopping condition and remove the listener if it
// has been reached.
var numIterations : int = 0;
var totalIterations : int = 100000;
Application.application.addEventListener(Event.ENTER_FRAME, runLoop);
private function runLoop(event : Event) : void
{
// Do work of iteration here.
numIterations++;
if(numIterations >= totalIterations)
{
Application.application.removeEventListener(Event.ENTER_FRAME,runLoop);
}
}
GREENTHREADING IN FLEX
15. Some Solutions
AND NOW FOR A LITTLE CODE…
// To break up an algorithm via a Timer
// 1. Initialize progress variables.
// 2. Initialize a Timer with a delay. Here delay ≈≈ time/frame.
// 3. Add listener for TimerEvent.TIMER that does main work of algorithm.
// 4. In handler check for stopping condition and call stop() on Timer if it
// has been reached.
var numIterations : int = 0;
var totalIterations : int = 100000;
var timer : Timer = new Timer(1000 / Application.application.stage.frameRate);
timer.addEventListener(TimerEvent.TIMER, runLoop);
timer.start();
private function runLoop(event : TimerEvent) : void
{
// Do work of iteration here.
numIterations++;
if(numIterations >= totalIterations)
{
timer.stop();
}
// Else next iteration will execute next TimerEvent.TIMER event.
}
GREENTHREADING IN FLEX
16. Some Solutions
The good:
Event Queue can process other events between
batches.
Application remains responsive.
GREENTHREADING IN FLEX
17. Some Solutions
The not-so-good:
Code becomes little more complex.
Can take much longer to finish the job:
Spread out over time.
More overhead.
Fine tune amount of work done and how often you do it.
Can be time-consuming for developer.
Might need to re-tune if code or data changes.
GREENTHREADING IN FLEX
18. Greenthreading
Multi-threading on FP:
Developers can’t access threading FP uses:
Networking
Watchers on your code for timeouts
True threading available via PixelBender:
Designed for media processing and to take advantage of ability of
shaders, filters, and blenders to run multi-threaded.
Works great if you can find a way to convert your problem space to
PIxelBender’s.
GREENTHREADING IN FLEX
19. Greenthreading
So what is a “green thread?”
Want to give developer more control over when code gets executed.
Can emulate threads in developer code, i.e., green threads.
Similar to how other platforms provide threading even for single
processor systems.
General idea:
Do as much work as possible in frame.
Leave enough time for other events to process, for screen to
update.
GREENTHREADING IN FLEX
20. Greenthreading
How does it work?
Specify some amount of time to leave for other events:
EPSILON
Break long-running code into basic blocks that will run
repeatedly.
Each time greenthread finishes with a block, check how
much total time used so far in frame.
If the total time used >= TIME_PER_FRAME - EPSILON,
stop running for now.
GREENTHREADING IN FLEX
21. EXECUTED BEFORE EPSILON
GREENTHREAD STARTS
2
AFTER 1 ITERATIONS
2
AFTER 2 ITERATIONS
2
AFTER X ITERATIONS
EXECUTED AFTER
GREENTHREAD PAUSES
2
WAITING FOR NEXT FRAME
GREENTHREADING
ARTIST (NOT-SO-MUCH) RENDERING
22. Greenthreading
Encapsulate all this as a class: GreenThread by
Charlie Hubbard.
http://code.google.com/p/greenthreads/
Hubbard’s class also provides statistics, progress
monitoring via events.
To use: convert your code block/algorithm/job etc.
to a GreenThread.
GREENTHREADING IN FLEX
23. Greenthreading
AND NOW FOR A LITTLE CODE…
public class MyGreenthreadAlgorithm extends GreenThread
{
// Called when start() called on a GreenThread
override public function initialize() : void
{
// Initialize variables needed.
progress = 0;
maximum = 100;
}
override public function run() : Boolean
{
// Do work of one iteration here.
progress++;
// Return true if done, false otherwise.
}
}
GREENTHREADING IN FLEX
24. ALGORITHM
1 ITERATION
DIVIDE + CONQUER ENTER_FRAME TIMER
1 2 1 2
LEFTOVER
TIME
INCREASE ITERATIONS
RUN PER FRAME
ENTER_FRAME TIMER GREENTHREADING EPSILON
1 2 1 2 1 2 KEY
SPECIFY EPSILON: SET AMOUNT
OF TIME LEFT IN FRAME FOR
PROCESSING OTHER EVENTS.
FILL UP REMAINING FRAME
TIME WITH ITERATIONS
GREENTHREADING VS OTHER SOLUTIONS
ARTIST (NOT-SO-MUCH) RENDERING, NOT DRAWN TO SCALE
25. Timer Timer
Original GreenThread
(1 loop/frame) (20k loop/frame)
Runtime 58 sec* ~11 hrs - 62 sec 85 sec
Slow Down None* V. Large Small Moderate
Responsive NOT
NO YES YES
? REALLY
*If the application doesn’t crash that is.
DEMO COMPARISON
RUNTIME AND RESPONSIVENESS
26. Greenthreading
The not-so-good:
Still have overhead.
More code complexity
Runtime increase
Still may need to make adjustments to time left
over to rest of events.
GREENTHREADING IN FLEX
27. Greenthreading
The good:
Application responsiveness
Greenthread determines how much work to do
itself given bounds.
Greenthread encapsulates management of time/
work. Makes some things neater.
GREENTHREADING IN FLEX
28. Greenthreading
But what about multi-threading?
Important to maintain EPSILON time to handle rest of the
execution and rendering of the frame.
Queue up Greenthreads as they are instantiated.
Time allocated to each Greenthread: (time for frame -
EPSILON) / # active Greenthreads.
When Greenthreads finish executing, they are removed from
queue.
Implemented in Hubbard’s library: just create as many
GreenThreads as needed.
GREENTHREADING IN FLEX
29. Credit Where Credit Is
Due
Doug Knudsen: “AIR, CSVs, and Mean Greenies
oh my!” @ cubicleman.com
Charlie Hubbard, “Actionscript and Concurrency”
@ wrongnotes.blogspot.com
Drew Cummins, “Green Threads” @
blog.generalrelativity.org
Jesse Warden, “Parsing & Rendering Lots of Data
in Flash Player” @ jessewarden.com
GREENTHREADING IN FLEX
30. Conclusion
Applications that have long-running code can hang because Event
Queue stalls.
To keep application responsive:
Break work down into small jobs
Trigger jobs at different time, give Event Queue a chance to
process other events.
Greenthreading: fit as much work into frame as possible, leave
time for other events.
Costs of greenthreading: more complex code, little longer runtime.
GREENTHREADING IN FLEX
31. Questions?
THANKS FOR COMING!
HUYEN TUE DAO
DAOTUEH@GMAIL.COM
QUEENCODEMONKEY @ TWITTER
WWW.QUEENCODEMONKEY.COM
GREENTHREADING IN FLEX
32. Links
Greenthreading
http://www.cubicleman.com/2009/03/08/air-csvs-and-mean-greenies-oh-my/
http://wrongnotes.blogspot.com/2009/02/concurrency-and-actionscript-part-
i-of.html
http://blog.generalrelativity.org/actionscript-30/green-threads/
http://jessewarden.com/2009/02/parsing-rendering-lots-of-data-in-flash-
player.html
Frame execution model
http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-
and-avm2/
http://www.onflex.org/ted/2005/07/flash-player-mental-model-elastic.php
GREENTHREADING IN FLEX
Editor's Notes
Frame event: especially important because where drawing of the stage occurs.
Bring up simple parser application code and the parsing loop and reiterate that because application keeps processing loop, application becomes unresponsive, hangs, beach ball of death.
Bring up simple parser application code and the parsing loop and reiterate that because application keeps processing loop, application becomes unresponsive, hangs, beach ball of death.
Now go to application code and show parser example using callLater
Now go to application code and show parser example using a Timer event.
So what we have here is a trade-off between a quicker-running application that&#x2019;s unresponsive and a responsive application that takes way too long to run.
So what we have here is a trade-off between a quicker-running application that&#x2019;s unresponsive and a responsive application that takes way too long to run.
Frame event: especially important because where drawing of the stage occurs.
Now go to main demo application and show green
Links to these blog posts are included at the end of my slides.