Better performance with WebWorkers Konsultaner GmbH & Co. KG Lugturmstr. 45 01809 Heidenau Tel: + 49 (0) 3 529 / 52 902 40 Fax: + 49 (0) 3 529 / 52 902 44 www.konsultaner.de [email protected]

About us

» Web technology agency » Java WebSocket-Server + sub protocol = connectanum » Several JavaScript Modules » PHP-CMS » Custom BI-Websoftware » Apps

What are WebWorkers

» Isolated Threads in JavaScript

Can i use caniuse.com/#feat=webworkers

caniuse.com/#search=shared

Why WebWorkers Why » Prevent ui-thread blocking » Enhance performance » (With) concurrent computation

Easy multithreading » No locking, no synchronization, no atomics » Immutable » Comes with simple message system » But no shared agiert memory

agiert / reagiert

Implementation index.js var worker = new Worker('doWork.js'); worker.addEventListener('message', function(e) { console.log('Worker said: ', e.data); }, false); worker.postMessage('Hello World');

doWorker.js self.addEventListener('message', function(e) { self.postMessage(e.data); }, false); Source: html5rocks.com

Implementation Easy to solve problems » XML-parsing » Just use one of a milltion tools to compensate it » i.e. https://github.com/tobiasnickel/tXml » Angular 2 runs in a WebWorker

» The missing load event » Write your own » When all your initialization (i.e. server requests) is done, send a ready message

» Serialization is really fast, everything important works as expected » Bigger data can be passed as ArrayBuffer in the transferList » BUT: Functions are not serializable! » I know eval, but I wouldn't use it » You can add functionality during your build process

Implementation

Non-trivial problems » WebWorker only provide a simple asynchronous message send and receive logic » Nice to have features

» Multiple threads » RPC calls » Promises » Progress events (thread.js) » If you prefer the actor pattern (akka.js)

Performance Serialization » Is serialization too slow? » http://runspired.github.io/webworker-performance/

» Chrome52 on this Laptop » ~14kbyte String => 133ms {String[]} => 238ms {String[]} as transferable => 290ms » ~35kbyte String => 303ms {*} => 968ms {*} => 611ms

Performance

Computing » Google says » In many cases you can move pure computational work to Web Workers, [...] Data manipulation or traversal, like sorting or searching, are often good fits for this model, as are loading and model generation

» But the worker has extra » Source load time » Creation time » Data transfer time

Source: https://developers.google.com/web/fundamentals/performance/rendering/optimize-javascript-execution

Performance

Computing » Load the Worker once, not for each computation » Measure performance Everything under 3-4ms is not worth thinking about [google] » Use worker when ever javascript blocks the ui-thread

Performance

Example with Ionic » Ionic app, page transition optimization » Transition from dashboard to a heavy list view » Ng-repeat is very slow » Manual DOM creation with angular services not too fast

» 3-4 Seks processing time on samsung galaxy S5 with crosswalk to finish the transition with ng-repeat » ~1Sek processing time in browser

Performance Profile not optimized » DOM generated in directive

Performance Profile not optimized » DOM generated in worker

Performance Example Calendar » Approves performance of ionic example (~26ms)

Performance Multicore » Calculate 2x mod 97777 using n threads on a Intel i7 6700 Quadcore (8 logical cores) @2.6GHz

Source: http://pmav.eu/stuff/javascript-webworkers/

Thank You!

Better performance with WebWorkers - GitHub

Chrome52 on this Laptop. » ~14kbyte. String => 133ms ... 3-4 Seks processing time on samsung galaxy S5 with crosswalk to finish the transition with ... Page 17 ...

1MB Sizes 78 Downloads 298 Views

Recommend Documents

Simulating Reflector Antenna Performance with GRASP9 - GitHub
Surfaces. – conic sections (e.g. parabolas, ellipsoids, etc.) – point cloud (e.g. shaped surface). – planes. – struts. – surface with errors. • Rim defined separately.

Better Backlog Prioritization - GitHub
good analysis is performed in every technique ... In an email thread conversation between Martin Burns and Joshua Arnold, the suggestion of making Time ...

On the Complexity and Performance of Parsing with ... - GitHub
seconds to parse only 31 lines of Python. ... Once these are fixed, PWD's performance improves to match that of other ...... usr/ftp/scan/CMU-CS-68-earley.pdf.

Improving UX through performance - GitHub
Page 10 ... I'm rebuilding the Android app for new markets ... A debug bridge for Android applications https://github.com/facebook/stetho ...

Achieving Predictable Performance through Better ...
netic algorithm followed the trend of memory controllers clustered along the ... trollers in the center of the chip, increasing escape complexity. ...... IEEE Micro,.

Building a Better Board Game - GitHub
Building a Better Board Game. Ryan Calme ... might garner from members of the site. ... A Pearson correlation value of 0.8 or greater indicates a reasonably good model fit. ..... 2 http://www.stat.berkeley.edu/~ledell/docs/dlab_ensembles.pdf ...

Choosing an Appropriate Performance Measure - GitHub
We compare the performance of the classifier (here, we use a support vector machine) ... Meeting Planner. Washington, DC: Society for Neuroscience, 2011.

OpenDaylight Performance Stress Tests Report v1.0 - GitHub
Jun 29, 2015 - For our evaluation we have used NSTAT [1], an open source en- vironment ... rameters), online performance and statistics monitoring, and.

CP2K with LIBXSMM - GitHub
make ARCH=Linux-x86-64-intel VERSION=psmp AVX=2. To target for instance “Knights ... //manual.cp2k.org/trunk/CP2K_INPUT/GLOBAL/DBCSR.html).

Java with Generators - GitHub
processes the control flow graph and transforms it into a state machine. This is required because we can then create states function SCOPEMANGLE(node).

Success story – Easier process, better performance! Services
Background. Appxplore is a mobile game development studio based in. Kuala Lumpur. Established in. 2011, it has published a number of titles to public and critical acclaim. Goal. To maximize total app monetization revenue via engaging rewarded ads wit

Use Wireless Microphone For Better Performance On Stage.pdf ...
Use Wireless Microphone For Better Performance On Stage.pdf. Use Wireless Microphone For Better Performance On Stage.pdf. Open. Extract. Open with.

Success story – Easier process, better performance! Services
Used AdMob rewarded ads and other rewarded networks through AdMob mediation for both Android and iOS games. Results. Ad revenue increased +15%. eCPM +56%. Ad revenue contribution 10%. “Implementing AdMob rewarded video and rewarded mediation helped

OpenBMS connection with CAN - GitHub
Arduino with BMS- and CAN-bus shield as BMS a master. - LTC6802-2 or LTC6803-2 based boards as cell-level boards. - CAN controlled Eltek Valere as a ...

with ZeroMQ and gevent - GitHub
Normally, the networking of distributed systems is ... Service Oriented .... while True: msg = socket.recv() print "Received", msg socket.send(msg). 1. 2. 3. 4. 5. 6. 7.

Getting Started with CodeXL - GitHub
10. Source Code View . ..... APU, a recent version of Radeon Software, and the OpenCL APP SDK. This document describes ...... lel_Processing_OpenCL_Programming_Guide-rev-2.7.pdf. For GPU ... trademarks of their respective companies.

Getting Started with Go - GitHub
Jul 23, 2015 - The majority of my experience is in PHP. I ventured into Ruby, ... Compiled, Statically Typed, Concurrent, Imperative language. Originally ...