SlideShare a Scribd company logo
Multithreading for
High Performance Real
Time Web Apps
@CoreyClarkPhD
@GameTheoryLabs
Who Am I?
!   Professor of Game and
Simulation Programming
!   Founder of Game Theory
Labs
! Nanoscale Semiconductor
Growth Kinetics
!   Flexible Embedded
Electronics for ABL
!   SWARM and C4ISR
Embedded Systems
!   Building HTML5 Web
Apps Utilizing:
!   Cloud Cluster
Computing
!   Game Technology
!   Artificial Intelligence
Modeling, Learning and
Optimization
What I Do:What I Did:
HTML5 JavaScript APIs
WebGL
WebSockets
Gamepad API
WebRTC
WebAudio
WebVideo
GetUserMediaFullscreen
The Sexy Ones….
And Then There Is
WebWorkers
Powerful…… But not Sexy
What I Want To Do Today
Bring the Sexy Back to WebWorkers
What Is A WebWorker And
What Can I Use It For…
!   Isolated Thread
!   Parallel Execution
!   JSON Message Based
Communication
!   No Shared Memory*
!   Asset Loading
!   Computationally
Intensive Processes
!   Increase Overall App
Performance via
Parallel Processing
!   Keeping UI Responsive
!   Take advantage of
multi-core processors
*Shared Objects discussed Later
What are the Limitations?
!   No Access:
!   DOM
!   Window
!   Document
!   Parent
!   Main App Memory/Objects
!   You Do Have Access To:
!   XHR
!   Navigator, Location
! setTimeout/setInterval
!   App Cache
!   Import Script
But First:
A Simple Demo
http://demo.jahovaos.com/JaHOVA/0v5_0/main.html?Console=threads2
Lets Talk Performance
!   Creating a First
WebWorker
!   Create a Second
WebWorker (same js file)
!   Sending Small/Normal
Sized Message
!   Sending Large (100K
Array Objects) Messages
Dependent on JS File
Seen >100ms
~ < 1ms
~ < 1ms
~10ms
WebWorker Variations
!   Inline
!   Dynamically created code file using BlobBuilder
!   External
!   Standard WebWorker, using a separate JavaScript File
!   Nested
! WebWorker Inception…. A worker within a worker
!   Shared
!   Worker that allows for communication between other windows
and iframes
Show Me The API
! wrk = new Worker(thread.js);
! wrk.postMessage(jsonObject);
! self.postMessage(jsonObject);
!   Callbacks
!   Message
!   Error
Show Me The API
! sw = new SharedWorker(thread.js, [“Worker Name”]);
! sw.port.start()
! sw.port.postMessaget(jsonObject)
! port.postMessage(jsonObject);
!   Callbacks
!   connect – (gets the port) e.port[0]
! port.onmessage
! port.onerror
Browser Support
! WebWorkers
!   Chrome, Safari, FireFox, IE10,
Opera
! iOS, FF Mobile, Blackberry
!   Shared Workers
!   Chrome, Safari, iOS, BlackBerry,
!   Nested
! FireFox
Is One Worker Enough?
Multi Tier Thread Architecture
Worker
Nested Worker
Nested Worker
Nested Worker
Window
iframe
Building a 3D Game using
HTML5
! WebWorker
!   Physics
!   Networking
!   AI
!   Main App
!   User Input
! WebGL*
*At some point may be possible to place in WebWorker
So With All These Threads….
Where do you sync the memory?
Lets Step Up Our Design
Thread
Thread
Thread / iframe
Thread / iframe
…
Thread
Thread Pool
Thread Manager
Shared
Memory
Omega Resistance v 0.1
!   Shared Workers (Chrome)
!   Physics
!   Networking
! Node.js server
!   Shared Memory
!   Multithreaded:
!   100% > 35 FPS
!   Single Threaded
!   55% < 30FPS
http://omega.gametheorylabs.com
Show Me The Numbers!
Can I Make It More
Complicated?
YES! Shared Objects
Main Application Web Worker
JavaScript
Object
Sample JavaScript Game Engine
Main App
GUI/HUD
WebGL
Thread
Manager
Entity Data
Entity Data
Thread
Controller
Physics
Thread
AI
Thread
Network
Thread*
*If possible
Asset Loading
When Apps Give Me….
I Get a WebWorker!
Omega Resistance 0v2
! WebGL
!   Gamepad API
!   3D Rigid Body Physics
!   AI Autonomous
Movement
! WebWorkers
http://or.gametheorylabs.com
Lessons Learned…
The Hard Way
!   Develop a way to properly identify them on Connection, or
Load SharedWorker Threads Serially
!   Initialize WebWorkers at Startup
!   Debugging used to really suck, but now it sucks normal
!   Minimize the number of messages
!   Careful with automated generated messages in nested/shared
worker architecture
!   Developed in single thread (With MT in mind), then
transition to multithread, IMHO
!   Careful with recursive JavaScript Entities that you want to
pass to WebWorker
Our Next Step
JaHOVA OS GEn3CIS
Questions?
Twitter/Facebook:
@CoreyClarkPhD
@GameTheoryLabs
Blog: blog.gametheorylabs.com
Dev Wiki: wiki.gametheorylabs.com
Git: git.gametheorylabs.com

More Related Content

What's hot

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Aaron Rosenberg
 
Testing your Single Page Application
Testing your Single Page ApplicationTesting your Single Page Application
Testing your Single Page Application
Wekoslav Stefanovski
 
ClubAJAX Basics - Server Communication
ClubAJAX Basics - Server CommunicationClubAJAX Basics - Server Communication
ClubAJAX Basics - Server Communication
Mike Wilcox
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
Irfan Maulana
 
MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015
Valeri Karpov
 
Blazor
BlazorBlazor
Drupal, Android and iPhone
Drupal, Android and iPhoneDrupal, Android and iPhone
Drupal, Android and iPhone
Alexandru Badiu
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and me
Jason Casden
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A Primer
Naveen S.R
 
Testing Single Page Webapp
Testing Single Page WebappTesting Single Page Webapp
Testing Single Page WebappAkshay Mathur
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous
 
Nodejs - Building a RESTful API
Nodejs - Building a RESTful APINodejs - Building a RESTful API
Nodejs - Building a RESTful APISang Cù
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
Mike Wilcox
 
Getting Started with HTML 5 Web workers
Getting Started with HTML 5 Web workersGetting Started with HTML 5 Web workers
Getting Started with HTML 5 Web workers
Flumes
 
The Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsThe Dark Side of Single Page Applications
The Dark Side of Single Page Applications
Dor Kalev
 
MEAN Stack - Google Developers Live 10/03/2013
MEAN Stack - Google Developers Live 10/03/2013MEAN Stack - Google Developers Live 10/03/2013
MEAN Stack - Google Developers Live 10/03/2013
Valeri Karpov
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB
Valeri Karpov
 
LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?
phegaro
 

What's hot (20)

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Testing your Single Page Application
Testing your Single Page ApplicationTesting your Single Page Application
Testing your Single Page Application
 
ClubAJAX Basics - Server Communication
ClubAJAX Basics - Server CommunicationClubAJAX Basics - Server Communication
ClubAJAX Basics - Server Communication
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015MongoDB MEAN Stack Webinar October 7, 2015
MongoDB MEAN Stack Webinar October 7, 2015
 
Blazor
BlazorBlazor
Blazor
 
Drupal, Android and iPhone
Drupal, Android and iPhoneDrupal, Android and iPhone
Drupal, Android and iPhone
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and me
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A Primer
 
Testing Single Page Webapp
Testing Single Page WebappTesting Single Page Webapp
Testing Single Page Webapp
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 
Nodejs - Building a RESTful API
Nodejs - Building a RESTful APINodejs - Building a RESTful API
Nodejs - Building a RESTful API
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
 
Getting Started with HTML 5 Web workers
Getting Started with HTML 5 Web workersGetting Started with HTML 5 Web workers
Getting Started with HTML 5 Web workers
 
The Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsThe Dark Side of Single Page Applications
The Dark Side of Single Page Applications
 
MEAN Stack - Google Developers Live 10/03/2013
MEAN Stack - Google Developers Live 10/03/2013MEAN Stack - Google Developers Live 10/03/2013
MEAN Stack - Google Developers Live 10/03/2013
 
20120802 timisoara
20120802 timisoara20120802 timisoara
20120802 timisoara
 
TDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDBTDD a REST API With Node.js and MongoDB
TDD a REST API With Node.js and MongoDB
 
LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?
 

Viewers also liked

Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesRay Toal
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrency
pgriess
 
Introduce native client
Introduce native clientIntroduce native client
Introduce native client
Young-Ho Cha
 
ENEA My Activities
ENEA My ActivitiesENEA My Activities
ENEA My Activities
matteodefelice
 
PELAJARAN MATEMATIKA SMP
PELAJARAN MATEMATIKA SMPPELAJARAN MATEMATIKA SMP
PELAJARAN MATEMATIKA SMPMade Bagiada
 
Presentation
PresentationPresentation
Presentation
Akul1501
 
Distributed Parallel Process Particle Swarm Optimization on Fixed Charge Netw...
Distributed Parallel Process Particle Swarm Optimization on Fixed Charge Netw...Distributed Parallel Process Particle Swarm Optimization on Fixed Charge Netw...
Distributed Parallel Process Particle Swarm Optimization on Fixed Charge Netw...
Corey Clark, Ph.D.
 
Evaluating Product System Behavior using Soft Computing in Product Structure ...
Evaluating Product System Behavior using Soft Computing in Product Structure ...Evaluating Product System Behavior using Soft Computing in Product Structure ...
Evaluating Product System Behavior using Soft Computing in Product Structure ...
Yatish Bathla
 
High Performance NodeJS
High Performance NodeJSHigh Performance NodeJS
High Performance NodeJS
Dicoding
 
SOLAR TRACKING SYSTEM BY USING MICROCONTROLLER
 SOLAR  TRACKING  SYSTEM  BY  USING  MICROCONTROLLER SOLAR  TRACKING  SYSTEM  BY  USING  MICROCONTROLLER
SOLAR TRACKING SYSTEM BY USING MICROCONTROLLER
JOLLUSUDARSHANREDDY
 
distribution system fault mangement
distribution system fault mangementdistribution system fault mangement
distribution system fault mangementManjunath Ds
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
garima931
 
Solar tree ppt
Solar tree pptSolar tree ppt
Solar tree ppt
dreamervikas
 
An Introduction to WebWorker - 01.26.12
An Introduction to WebWorker - 01.26.12An Introduction to WebWorker - 01.26.12
An Introduction to WebWorker - 01.26.12Digiflare
 
Solar panel Technology ppt
Solar panel Technology pptSolar panel Technology ppt
Solar panel Technology pptGourav Kumar
 
Solar energy ppt
Solar energy pptSolar energy ppt
Solar energy pptshubhajit_b
 

Viewers also liked (16)

Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrency
 
Introduce native client
Introduce native clientIntroduce native client
Introduce native client
 
ENEA My Activities
ENEA My ActivitiesENEA My Activities
ENEA My Activities
 
PELAJARAN MATEMATIKA SMP
PELAJARAN MATEMATIKA SMPPELAJARAN MATEMATIKA SMP
PELAJARAN MATEMATIKA SMP
 
Presentation
PresentationPresentation
Presentation
 
Distributed Parallel Process Particle Swarm Optimization on Fixed Charge Netw...
Distributed Parallel Process Particle Swarm Optimization on Fixed Charge Netw...Distributed Parallel Process Particle Swarm Optimization on Fixed Charge Netw...
Distributed Parallel Process Particle Swarm Optimization on Fixed Charge Netw...
 
Evaluating Product System Behavior using Soft Computing in Product Structure ...
Evaluating Product System Behavior using Soft Computing in Product Structure ...Evaluating Product System Behavior using Soft Computing in Product Structure ...
Evaluating Product System Behavior using Soft Computing in Product Structure ...
 
High Performance NodeJS
High Performance NodeJSHigh Performance NodeJS
High Performance NodeJS
 
SOLAR TRACKING SYSTEM BY USING MICROCONTROLLER
 SOLAR  TRACKING  SYSTEM  BY  USING  MICROCONTROLLER SOLAR  TRACKING  SYSTEM  BY  USING  MICROCONTROLLER
SOLAR TRACKING SYSTEM BY USING MICROCONTROLLER
 
distribution system fault mangement
distribution system fault mangementdistribution system fault mangement
distribution system fault mangement
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Solar tree ppt
Solar tree pptSolar tree ppt
Solar tree ppt
 
An Introduction to WebWorker - 01.26.12
An Introduction to WebWorker - 01.26.12An Introduction to WebWorker - 01.26.12
An Introduction to WebWorker - 01.26.12
 
Solar panel Technology ppt
Solar panel Technology pptSolar panel Technology ppt
Solar panel Technology ppt
 
Solar energy ppt
Solar energy pptSolar energy ppt
Solar energy ppt
 

Similar to Bringing The Sexy Back To WebWorkers

Taking The Cloud Native
Taking The Cloud NativeTaking The Cloud Native
Taking The Cloud Native
Corey Clark, Ph.D.
 
Apache Flex and the imperfect Web
Apache Flex and the imperfect WebApache Flex and the imperfect Web
Apache Flex and the imperfect Web
masuland
 
Realtime rocks
Realtime rocksRealtime rocks
Realtime rocks
Vanbosse
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
Jackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.jsguileen
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsIn Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsSpike Brehm
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
Alexandre Morgaut
 
XSS Without Browser
XSS Without BrowserXSS Without Browser
XSS Without Browser
kosborn
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
drupalcampest
 
Meebo performance ny_web_performance
Meebo performance ny_web_performanceMeebo performance ny_web_performance
Meebo performance ny_web_performance
marcuswestin
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureSimon Willison
 
WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014Minko3D
 
How to be a Developer
How to be a DeveloperHow to be a Developer
How to be a Developer
Reza Nurfachmi
 
Developer &lt; eat love code >
Developer   &lt; eat love code >Developer   &lt; eat love code >
Developer &lt; eat love code >
Rizky Ariestiyansyah
 
Node Web Development 2nd Edition: Chapter1 About Node
Node Web Development 2nd Edition: Chapter1 About NodeNode Web Development 2nd Edition: Chapter1 About Node
Node Web Development 2nd Edition: Chapter1 About Node
Rick Chang
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
async_io
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
David Padbury
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 

Similar to Bringing The Sexy Back To WebWorkers (20)

Taking The Cloud Native
Taking The Cloud NativeTaking The Cloud Native
Taking The Cloud Native
 
Apache Flex and the imperfect Web
Apache Flex and the imperfect WebApache Flex and the imperfect Web
Apache Flex and the imperfect Web
 
Realtime rocks
Realtime rocksRealtime rocks
Realtime rocks
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsIn Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
 
XSS Without Browser
XSS Without BrowserXSS Without Browser
XSS Without Browser
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
Meebo performance ny_web_performance
Meebo performance ny_web_performanceMeebo performance ny_web_performance
Meebo performance ny_web_performance
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
 
WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014
 
How to be a Developer
How to be a DeveloperHow to be a Developer
How to be a Developer
 
Developer &lt; eat love code >
Developer   &lt; eat love code >Developer   &lt; eat love code >
Developer &lt; eat love code >
 
Node Web Development 2nd Edition: Chapter1 About Node
Node Web Development 2nd Edition: Chapter1 About NodeNode Web Development 2nd Edition: Chapter1 About Node
Node Web Development 2nd Edition: Chapter1 About Node
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 

Bringing The Sexy Back To WebWorkers

  • 1. Multithreading for High Performance Real Time Web Apps @CoreyClarkPhD @GameTheoryLabs
  • 2. Who Am I? !   Professor of Game and Simulation Programming !   Founder of Game Theory Labs ! Nanoscale Semiconductor Growth Kinetics !   Flexible Embedded Electronics for ABL !   SWARM and C4ISR Embedded Systems !   Building HTML5 Web Apps Utilizing: !   Cloud Cluster Computing !   Game Technology !   Artificial Intelligence Modeling, Learning and Optimization What I Do:What I Did:
  • 3. HTML5 JavaScript APIs WebGL WebSockets Gamepad API WebRTC WebAudio WebVideo GetUserMediaFullscreen The Sexy Ones….
  • 4. And Then There Is WebWorkers Powerful…… But not Sexy
  • 5. What I Want To Do Today Bring the Sexy Back to WebWorkers
  • 6. What Is A WebWorker And What Can I Use It For… !   Isolated Thread !   Parallel Execution !   JSON Message Based Communication !   No Shared Memory* !   Asset Loading !   Computationally Intensive Processes !   Increase Overall App Performance via Parallel Processing !   Keeping UI Responsive !   Take advantage of multi-core processors *Shared Objects discussed Later
  • 7. What are the Limitations? !   No Access: !   DOM !   Window !   Document !   Parent !   Main App Memory/Objects !   You Do Have Access To: !   XHR !   Navigator, Location ! setTimeout/setInterval !   App Cache !   Import Script
  • 8. But First: A Simple Demo http://demo.jahovaos.com/JaHOVA/0v5_0/main.html?Console=threads2
  • 9. Lets Talk Performance !   Creating a First WebWorker !   Create a Second WebWorker (same js file) !   Sending Small/Normal Sized Message !   Sending Large (100K Array Objects) Messages Dependent on JS File Seen >100ms ~ < 1ms ~ < 1ms ~10ms
  • 10. WebWorker Variations !   Inline !   Dynamically created code file using BlobBuilder !   External !   Standard WebWorker, using a separate JavaScript File !   Nested ! WebWorker Inception…. A worker within a worker !   Shared !   Worker that allows for communication between other windows and iframes
  • 11. Show Me The API ! wrk = new Worker(thread.js); ! wrk.postMessage(jsonObject); ! self.postMessage(jsonObject); !   Callbacks !   Message !   Error
  • 12. Show Me The API ! sw = new SharedWorker(thread.js, [“Worker Name”]); ! sw.port.start() ! sw.port.postMessaget(jsonObject) ! port.postMessage(jsonObject); !   Callbacks !   connect – (gets the port) e.port[0] ! port.onmessage ! port.onerror
  • 13. Browser Support ! WebWorkers !   Chrome, Safari, FireFox, IE10, Opera ! iOS, FF Mobile, Blackberry !   Shared Workers !   Chrome, Safari, iOS, BlackBerry, !   Nested ! FireFox
  • 14. Is One Worker Enough? Multi Tier Thread Architecture Worker Nested Worker Nested Worker Nested Worker Window iframe
  • 15. Building a 3D Game using HTML5 ! WebWorker !   Physics !   Networking !   AI !   Main App !   User Input ! WebGL* *At some point may be possible to place in WebWorker So With All These Threads…. Where do you sync the memory?
  • 16. Lets Step Up Our Design Thread Thread Thread / iframe Thread / iframe … Thread Thread Pool Thread Manager Shared Memory
  • 17. Omega Resistance v 0.1 !   Shared Workers (Chrome) !   Physics !   Networking ! Node.js server !   Shared Memory !   Multithreaded: !   100% > 35 FPS !   Single Threaded !   55% < 30FPS http://omega.gametheorylabs.com
  • 18. Show Me The Numbers!
  • 19. Can I Make It More Complicated? YES! Shared Objects Main Application Web Worker JavaScript Object
  • 20. Sample JavaScript Game Engine Main App GUI/HUD WebGL Thread Manager Entity Data Entity Data Thread Controller Physics Thread AI Thread Network Thread* *If possible
  • 21. Asset Loading When Apps Give Me…. I Get a WebWorker!
  • 22. Omega Resistance 0v2 ! WebGL !   Gamepad API !   3D Rigid Body Physics !   AI Autonomous Movement ! WebWorkers
  • 24. Lessons Learned… The Hard Way !   Develop a way to properly identify them on Connection, or Load SharedWorker Threads Serially !   Initialize WebWorkers at Startup !   Debugging used to really suck, but now it sucks normal !   Minimize the number of messages !   Careful with automated generated messages in nested/shared worker architecture !   Developed in single thread (With MT in mind), then transition to multithread, IMHO !   Careful with recursive JavaScript Entities that you want to pass to WebWorker
  • 25. Our Next Step JaHOVA OS GEn3CIS
  • 26.