Skip to Content
Author's profile photo Chris Whealy

Off Topic (but really cool!) – Parallel Processing in JavaScript

Hi All

Firstly and foremost, I must state categorically that SAPUI5 does not support parallel processing in JavaScript.  I’m just posting this blog here to raise awareness of a new processing capability in JavaScript.

Ok, let’s go off-topic now:

Like it or not, technology is marching on at a relentless pace.  10 years ago, JavaScript was little more than a toy scripting language and multi-core processors were exotic devices found only in research labs.  Now however, JavaScript is the language of the Web and multi-core processors are a common place feature in all but the most basic computing devices.

Now that it is taken for granted that business applications should have a Web-based user interface, it makes sense to examine how JavaScript can make use of the power of multi-core processors.

This is exactly what Intel has done with their GitHub project called River Trail.  This is a parallel compiler that will allow JavaScript coding to take full advantage of the multi-core processor on your computer.

I’ve written a demo using the River Trail functionality that plots the Mandelbrot set in both sequential and parallel calculation modes in order for you to see the performance improvements that are possible.  The performance improvements you see will be roughly a factor of the number of CPU cores available on your computer.  For instance, I have 8 cores on my MacBook Pro; therefore, I see approximately an 8-fold performance increase.

A word of caution though about parallel processing…

  • Don’t drink too much parallel processing Kool Aid here!  There is no software (and never will be) that can magically “parallelise” your sequentially written code.  If someone tells you there is, then you can be certain they don’t know what they’re talking about!
  • Parallel processing is not “a clever way to run my existing code faster”; it’s a completely new design paradigm that demands a whole new way of thinking (and that’s the painful part).
  • In order to take advantage of the processing power of multi-core CPU, you must write software that specifically focuses on solving the problem in parallel manner.  This style of coding is much closer to functional programming than the more traditional imperative style of coding currently used in almost all of SAP’s business software.

And about River Trail…

  • River Trail is a pilot project from Intel available on GitHub and as such, has various limitations.  For instance, at the moment River Trail only uses single precision floating point numbers, so you cannot zoom into the Mandelbrot set as far in parallel mode as you can when using sequential mode (regular JavaScript uses double precision floats).
  • River Trail is shipped as an extension to Firefox.  Therefore, this functionality is only available if you are using an up to date version of Firefox.
  • All users must install the River Trail extension for Firefox.  Choose the latest version available here.
  • For Windows users, you must additionally install Intel’s OpenCL SDK, otherwise the River Trail compiler will fail.
  • You can view the demo using other browsers, but the coding will only run in sequential mode; therefore, no performance difference will be visible.

To avoid disappointment, please follow the setup instructions.

There is also a full discussion of the approach used to write parallel software, the coding used to implement this demo and of course, the demo itself.

Have fun, and I hope thinking in parallel doesn’t hurt your brain too much…

Chris W

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.