Threading Support

From RuntimeWiki

Jump to: navigation, search

Contents

Title

JavaScript Threading/Sandbox Support

Detailed write-up

Description

Threading is extremely useful construct, and explicitly creating threads to utilize modern multi-core systems could greatly benefit the performance of CPU intensive JavaScript applications. Furthermore, and message-passing/vat based threading system also provides a construct for sandboxing JavaScript.

Why Is This Important?

JavaScript is single-threaded which severely limits the ability to utilize modern hardware.

What exists today?

Google Gears provides a worker pool API [[1]] that allows you to create threads/vats and communicate with them through message-passing. I think this is a great model for introduction into the browsers.

Discussion

In this section, the contributors should express their opinions about this feature request, such as providing particular technical analysis or describing in prose why this feature is important (or not). It is recommended that each contributor create his own level-3 sub-section (e.g., === Jon Ferraiolo Comments ===).

It is OK for others to insert comments within other people's sections, but as a courtesy please make sure that it is clear which part of the section is original and which section are annotative comments. For example, perhaps annotative comments would be colorized (e.g., enclosed by <span style="color:red">JON: Here is what I think about what you are saying.</span>).

Brad Neuberg's comments

This feature becomes really important when you've got a local SQLite database for offline use or performance caching, such as with Gears or HTML 5. Imagine that you are constantly downloading data in the background that you cache into the local database, or are querying the database to update a UI. Databases are generally IO-bound, which means they are hitting the disk all the time as you update or query them. If this is on the UI thread then the browser starts getting really jerky and unresponsive. This is one of the biggest reasons Gears has this, so you can do advanced DB work without destroying the UI. You can create a Gears worker in the background that uses XHR to ping a server regularly to upload or download new data, and then cache it into the relational database or query the database without destroying the UI. Disclosure: I work with Google and the Gears team.

Coach Wei's comments

This feature is closely related to the JavaScript Pause Release feature request. Maybe we should merge these two into one. JavaScript Pause Release is a simpler request that does not ask for full threading support, but still enables developers to control the execution flow by "yielding" from time to time. Full threading support would be nice, but it comes at a cost of significantly complicates Javascript language. There is big advantage of being a single threaded language that developers don't need to worry too much about threading. I'm perfectly happy with Javascript staying as a single threaded language, but the current model that lacks support for basic capability to "pause" and "yield" to system VM is making it hard to write long running loops, etc.

Phase II Voting

More about this later.

Personal tools