On Sat, May 18, 2013 at 3:09 AM, David Rajchenbach-Teller
<dtel...@mozilla.com> wrote:
>         Hi everyone,
>
>   As part of the ongoing effort to make (Chrome) Workers useful for
> platform refactorings, we have been working on a lightweight module
> loader for workers (bug 872421). This loader implements a minimal
> version of CommonJS modules, aka require.js.
>
>
> Example:
>
> // Setup the loader. We need this once per worker.
> importScripts("resource://gre/modules/workers/loader.js");
>
> // Import a few modules
> let Logger = require("resource://gre/modules/workers/logger.js");
> let Storage = require("resource://gre/modules/workers/storage.js");
>
> // ...
> // All values that are not exported are private to the module
> // ...
>
> exports.foo = function() { ... } // Export a value |foo|
> exports.bar = 5; // Export a value |bar|
>
>
>
> Once this loader lands, we will need some convention for where to place
> modules for workers. Unfortunately, main thread modules (both .jsm and
> Jetpack) can generally not be used by worker, due to different module
> semantics, and more importantly due to the fact that most main thread
> modules depend indirectly on XPCOM/XPConnect.
>
> Given that main thread modules are rooted in
>  resource://gre/modules/
> and Jetpack modules are rooted in
>  resource://gre/modules/commonjs/
> I would like to place worker modules in
>  resource://gre/modules/workers/
>
> Any comments?

My main concern is that Workers created by Gecko are really expensive
memory-wise. See the thread started by Justin Lebar titled "Rethinking
the amount of system JS we use in Gecko on B2G".

The short of it is that each Worker requires a separate JS Runtime and
we simply haven't optimize runtimes for having lots of them. This is
especially a problem for B2G where we are very short on memory and
where we are running multiple copies of Gecko.

I would expect the same thing to be an issue on Firefox for Android,
though maybe less so since we're generally running on higher-end
hardware with more memory.

So creating Workers from frontend desktop-only code seems fine. But
it's something that would worry me if we start doing in cross platform
Gecko code.

/ Jonas
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to