Web Workers: A Draft Recommendation to Allow Parallelism in Scripts
Most modern Web pages run scripts. So far, there are many limitations to allow these scripts to take advantage of multicore microprocessors. However, Web Workers is a draft specification that defines an API to allow Web application authors to spawn background workers running scripts in parallel.
There is a German proverb that says "Wer A sagt, muss auch B sagen". In for a penny, in for a pound. If you start something, you have to finish it. If you say A, then you also have to say B.
The WHATWG (Web Hypertext Application Technology Working Group) community has a draft recommendation for Web Workers. This is a work in progress. Besides, the W3C Web Apps WG is also producing this specification. Therefore, we should expect full support for Web Workers in HTML 5.
This specification defines an API for running scripts in the background independently of any user interface scripts. This way, developers can create more responsive Web pages. The long-running scripts can work in the background, in an independent thread and the UI scripts can run on another thread (the main UI thread). The browser is responsible of assigning threads to each Worker instance. A well-designed browser should run each worker in an independent thread, to favor parallelism. As happens with heavyweight threading, Worker instances have a high start-up cost and a high per-instance memory footprint.
The specification allows message-passing as the coordination mechanism. Thus, it allows developers to create multithreaded scripting, capable of exploiting modern multicore microprocessors.
The new API is really very simple. However, it is necessary to understand many multicore, message-passing and threading concepts before trying to use it. The scripts don't use direct threading, however, the Web browsers implementing this API will create independent threads for each new Worker instance. Developers can work with event listeners and direct channels. The direct channels really simplify the communications between Worker instances.
Using Web Workers, the user interface should't be blocked anymore. There's going to be a new way of designing and developing scripts for Web pages. Now, the scripts are also going to be able to take advantage of multicore microprocessors.
Do you have to wait for HTML 5? No, you don't. You can begin testing Web Workers in two Web browsers using JavaScript. FireFox 3.5 and Safari 4 already include support for Web Workers (draft). Therefore, if you are planning to create more responsive and faster scripts for your Web pages, you can begin working right now. Nonetheless, you have to take into account that it is a work in progress. For this reason, the specification might change over time.
There is a very interesting unofficial Web Worker sample test. You can run it using FireFox 3.5 (or greater) and Safari 4 (or greater). It was developed by Dennis Forbes, modifying an original "single-threaded" SunSpider JavaScript Benchmark.
You can select a Repeat Count value and the number of desired Web Workers. As aforementioned, Worker instances have a high start-up cost, therefore it is very important to use 10 as the minimum Repeat Count value. The test performs many heterogeneous algorithms using JavaScript and as many Web Workers as specified.
The following screenshots show the test running with different numbers of Worker instances (from 1 to 4) using a quad-core microprocessor. You can check the graph shown in the Windows Task manager.
Developers will be able to create scalable scripts using Web Workers. Multicore programming is also important for Web developers.
Parallel Pattern 5: Stencil
All memory addresses used for reads are expressed as offsets
Distributing Work Across Cores Using .NET
A roll-your-own ThreadPool implementationLooking For The Lost Packets: Part 2
Looking For The Lost Packets: Part 1
- Intel Parallel Studio; Download the free eval today!
- Parallelism Breakthrough Video Series; Watch and learn more about Intel® Parallel Studio
- 2009 Intel Software Webinar Series; View On-Demand webinars
- Coding for Multi-core Processes; Intel® Compiler Pro eBook
- Performance Through Parallelism; Intel® Tuning for Vista eBook
- Intel® Software Network; Connect with developers and Intel engineers
-
February 18, 2010
Lock Contention, Using Intel Parallel Studio to Improve Performance
Speaker: Vasanth Tovinkere, Software Engineer, Intel Corporation (Bio)Vasanth Tovinkere is a software engineer in the Developer Products Division (DPD) at Intel. His current role involves defining novel approaches to understanding and visualizing parallel performance and consulting with strategic customers to help them prepare and deliver code for the multicore world. Vasanth has been involved in the development of automatic semantic event detectors for digital sports technologies in Intel Labs. He also has been awarded three patents and has two patents pending.
Abstract:
Discover how easy it is to use the power of Microsoft Visual Studio and Intel Parallel Studio to find performance issues due to lock contention in threaded applications. This ensures that shipped applications can take better advantage of multicore processors. In this webcast, we provide live demonstrations that show how to identify lock contentions issues with Visual Studio and Intel Parallel Studio, an add-in to Visual Studio that helps developers create fast, reliable code on multicore processors.t.



