Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/happymaa/public_html/coderchrismills.com/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340
River Trail and Web Workers – Chris Mills Press "Enter" to skip to content

River Trail and Web Workers

A few weeks ago I wrote a post comparing different implementations of a frustum culling algorithm between Chrome and Firefox. The purpose of that post was to investigate the differences between the two browsers with respect to how the code was laid out. In that post I mention that the next step was to compare River Trail with Web Workers. The starting point for this will be the code from the divergentcoder.com post on River Trail. To make sure it’s an even test, I’ve included output for Web Workers, River Trail, and sequential JavaScript.

The sphere count has been increased from 16384 to 262144 per iteration. A random number of iterations with a range from 1 to 25 are chosen with each button press for a given test. Sixteen workers are created during the construction of the WWCuller class and are reused for each iteration. Each worker processes 16384 spheres so the hope is that even with the larger sphere count, the times will be similar to the original test a few weeks ago. Results can be found below and the code is available on my github page.



Goes with out saying, but Chrome does not like the Web Workers with my implementation. V8 is incredibly fast, in some cases it’s almost as fast as Firefox with the Web Workers. It’s also all over the place, how does five iterations take 183s and eighteen iterations take 61s. It makes not sense to me and it’s something I’m going to have to look into.

On to Firefox. River Trail and Web Workers are about 14x to 18x faster than sequential JavaScript, a very nice speed bump indeed and moreover, they’re actually pretty close to each other. Seeing this has me really excited for Web Workers, especially with some of the array operations in ECMAScript 5 like filter. Just need to figure out why Chrome is so vastly different. Would be awesome if I could get Chrome to see the same double diget improvement.

Special thanks to +Chris Lentini who actually ran these test on his machine as I was unable to get River Trail running on my laptop. I’ll be stepping away from pure JavaScript posts for a few weeks as I’m going to be turning my attention to Unity3D so you’ll probably see a mix of the two for a bit. iOS people, I’m working on an iCloud post so be looking out for that.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *