Skip to content

src: experimental green threads implementation - #67288

Open
jasnell wants to merge 39 commits into
nodejs:mainfrom
jasnell:green-threads
Open

jasnell wants to merge 39 commits into
nodejs:mainfrom
jasnell:green-threads

Conversation

@jasnell

@jasnell jasnell commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

This is an experiment... opening for feedback. This is ready for review.

This implements green threads for Node.js. A green thread is a lightweight kind of worker. It has its own V8 isolate with no Node.js APIs. They run on a small pool of physical threads that they share, instead of each getting an OS thread and event loop like a worker thread. Each one gets work from the host through messages, RPC calls, or its module's exports, and every piece of work runs in an invocation context of its own. Each green thread can have limits on CPU time and memory, and the host can terminate it. This makes them cheap to start and to keep around in large numbers, and suited to running many small, untrusted pieces of code, such as plugins, per-tenant handlers, or user-supplied scripts.

const { GreenThread } = require('node:green_threads');

const greenThread = new GreenThread(`
  onmessage = ({ data }) => postMessage(data * 2);
`);
greenThread.on('message', (value) => {
  console.log(value);  // Prints: 42
  greenThread.terminate();
});
greenThread.postMessage(21);

For later, the plan is to add the following APIs (but not in this PR)

  • TextEncoder/TextDecoder
  • URL/URLSearchParams
  • structuredClone()
Details

Compared with worker threads

Green threads have real advantages over workers, in specific areas:

  • Memory: 2–6× less per instance, depending on the build and the
    isolate-group setting. A thousand tenants take about 1 GB instead of 6.7 GB.
  • Startup: up to about 80× faster with a warm pool (about 20 µs each).
  • Many instances: 1000 instances share 8 OS threads instead of using
    1000, and serve about 15–20% more requests per second.
  • Sandboxing: no Node.js APIs, plus per-instance CPU-time and memory
    limits.

They don't win on the speed of a single message, and they can't spread heavy
computation across all cores, since the pool is capped at 8 threads.

Setup for this performance comparison

  • Machine: 88 CPUs, 250 GB RAM, Linux x64.
  • Two builds:
    • Release: the default build, without pointer compression. It doesn't
      support isolate groups, so every green thread is in V8's default group.
    • Pointer compression: supports isolate groups. By default, each green
      thread is in an isolate group of its own.
  • Green thread pool: 8 threads (kMaxPoolThreads).

Each measurement runs in a fresh child process, so that memory numbers don't
include what earlier measurements left behind.

Kinds of green threads measured:

Kind Meaning
green Default options: an isolate group of its own where supported
green-default isolateGroup: 'default', V8's default isolate group
green-shared One IsolateGroup shared by all instances
green-warm Default options, taken from a warm pool filled beforehand

Memory and startup

1000 idle instances, started at once, measured once each has sent a message.

RSS per instance Starts per second OS threads
Worker 6.7–7.9 MB ~720 1000
Green, Release build 5.2 MB ~750 8
Green, pointer compression (own isolate group) 2.8 MB ~1,220 8
Green, pointer compression (isolateGroup: 'default') 2.6 MB ~810 8
Green, shared IsolateGroup 1.03 MB ~1,590 8
Green, from a warm pool same as cold 44,000–66,000 8
  • Memory: a green thread uses 1.5× to 6.5× less memory than a worker. A
    worker carries a whole Node.js environment, an event loop and an OS thread
    with its stack. A green thread is a V8 isolate with a small runtime.
  • Threads: green threads share a pool of 8 threads, however many there
    are.
  • Warm pool: setWarmPoolSize(n) prepares isolates in advance, so
    starting a green thread takes about 20 µs. Workers have no equivalent.
  • Cold start is only slightly faster than a worker's, except with a
    shared isolate group.

Speed

Message round trips

Sequential round trips with one instance.

Round trips per second Latency
Green ~57,000 ~17.5 µs
Worker ~61,000 ~16.5 µs

Workers are about 5% faster per message.

CPU-bound tasks

2000 tasks of fib(27), each executor taking the next task once it's done.
Release build.

Tasks per second Time
Green ×8 2,466 811 ms
Green ×2000 (one per task) 2,226 898 ms
Worker ×8 2,478 807 ms
Worker ×88 9,759 205 ms

At equal parallelism, CPU-bound code runs at the same speed. Green threads
can't use more than 8 cores, though, so for heavy parallel computation
workers win clearly. The cap is a choice in this implementation, not
inherent, and could be made configurable.

Many tenants

1000 tenants, each with code and state of its own, serving 50,000 requests
spread over all of them, 64 at a time.

All started Requests per second RSS total
Worker (Release) 1,653 ms ~129,000 7,974 MB
Green (Release) 1,332 ms ~150,000 5,267 MB
Worker (pointer compression) 1,387 ms ~126,000 6,725 MB
Green (pointer compression) 836 ms ~149,000 2,883 MB
Green, shared IsolateGroup 632 ms ~149,000 1,112 MB

Green threads serve about 15–20% more requests, since 8 pool threads don't
compete for the CPU the way 1000 OS threads do.

Runaway code

One of 100 tenants runs into an endless loop, while the others keep serving.

Stopped by Stopped after Others served in 200 ms
Green ERR_GREEN_THREAD_CPU_LIMIT (maxTaskCpuTimeMs: 50) ~60 ms ~35,000
Worker A host timer, then terminate() ~70 ms ~31,500

Both stop it. Green threads do it with a limit on CPU time, which the runtime
enforces. Workers need a timer by wall time on the host, which also stops
code that's only waiting.

What's easier to build: a plugin host

The same plugin host, built with each. It runs five plugins, which are ES
modules exporting transform(text). Plugins can import a shared module, and
call back into the host for configuration and logging. Three of them
misbehave.

Plugin Green threads Workers
upper, reverse (well-behaved) Work Work
spin (endless loop) ERR_GREEN_THREAD_CPU_LIMIT after 100 ms of CPU time The host's own wall-clock timeout, which also stops plugins that are only waiting
hog (allocates ArrayBuffers) Allocation fails at the 32 MB maxMemoryMb limit Not limited, since resourceLimits only cover the JS heap. Reached 91 MB within the 100 ms timeout
fail (throws with a code) Error arrives with code: 'ERR_PLUGIN' Only with hand-written error forwarding

The green thread version is 43 lines:

const plugin = new GreenThread(source, {
  type: 'module',
  filename: `file:///plugins/${name}/index.js`,
  modules: plugins.shared,
  env: {
    async config(key) { return plugins.config[key]; },
    log(...args) { console.log(`[${name}]`, ...args); },
  },
  resourceLimits: { maxTaskCpuTimeMs: 100, maxMemoryMb: 32 },
});
const { transform } = await plugin.exports;
console.log(await transform('hello world'));

The worker version is 155 lines, since it has to build what green threads
provide:

  • Module loading: workers load modules from files or URLs, so the
    plugins are written to a temporary directory. Green threads take a
    modules bundle and resolve() / load() hooks.
  • Calls in both directions: workers need call IDs, a table of pending
    calls, and error forwarding, roughly what Comlink does. Green threads get
    exports and env as RPC stubs.
  • Limits: workers have no CPU-time limit and no ArrayBuffer limit.
    Green threads have both.
  • Isolation: worker plugins have all of Node.js' APIs, including
    require('fs'). The permission model applies to the whole process, so it
    can't restrict a single worker. Green threads have no Node.js APIs at all:
    they can only do what the host passes them. This is the biggest
    qualitative difference.

When to use which

Use green threads for:

  • Multi-tenant or serverless-style hosting of many small handlers.
  • Plugin and extension systems that run untrusted code.
  • User-supplied scripts, rules, or transforms that need CPU and memory
    limits.
  • Many short-lived or mostly idle units of code, where startup time and
    memory per instance matter.

Use workers for:

  • Code that needs Node.js' APIs (fs, net, child_process), or npm
    packages that use them.
  • Heavy parallel computation across all cores, while the green thread pool
    is capped at 8 threads.
  • Blocking code: Atomics.wait() and synchronous waits are disabled in green
    threads, since a blocked isolate would hold up a shared pool thread.
  • A few long-lived instances, where the cost per instance doesn't matter.

Caveats

  • The pointer-compression numbers come from the build at f14fd2d7548,
    which doesn't have the ES modules and errors commits. These scenarios don't
    use either.
  • The warm-pool numbers for the pointer-compression build come from a later
    run than the rest of its table. The first run used a setting that bypassed
    the pool.
  • Worker startup throughput depends on the number of cores. On smaller
    machines, the gap is likely larger.
  • Some JIT-compiled loops ignore termination, a V8 bug. Green threads rely on
    a watchdog that abandons such isolates. Workers are affected by the same
    bug when terminated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/gyp
  • @nodejs/loaders
  • @nodejs/performance
  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Nov 6, 2026
@jasnell
jasnell requested review from addaleax and mcollina November 9, 2026 18:01
@glenjamin

Copy link
Copy Markdown
Contributor

I'm not clear what the etiquette is for feedback on things like this from random Node.js users, so if this isn't the place for it please let me know / delete/edit this as appropriate.

This seems really neat, but from reading the comparisons it got me wondering:

How many of the benefits are inherent to what green-threads can do, and how many of them are things that could conceivably be added to the existing workers implementation?

@ljharb

ljharb commented Nov 12, 2026

Copy link
Copy Markdown
Member

@jasnell does each green thread still have its own JS environment, like workers and worker threads?

@jasnell

jasnell commented Nov 12, 2026 •

Copy link
Copy Markdown
Member Author

@ljharb:

does each green thread still have its own JS environment, like workers and worker threads?
Not a full Node.js environment, no. That's intentional. You won't get the full set of globals and imports go to the parent rather than to the module system.

@jasnell

jasnell commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

@glenjamin:

How many of the benefits are inherent to what green-threads can do, and how many of them are things that could conceivably be added to the existing workers implementation?

The benefits realized here are because they are not implemented the way existing workers are. Specifically, a green thread is not bound to a single physical thread the way a worker thread is. A green thread does not have an entire Node.js Environment associated with it. It doesn't have the full set of globals. And so forth. That is, we get the benefits here by subtracting from existing workers implementation and not adding to it.

@ljharb

ljharb commented Nov 12, 2026

Copy link
Copy Markdown
Member

Is it possible to directly share objects between green threads?

@jasnell

jasnell commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Share-ish. You can postMessage values to it that are structured cloned. There's also an rpc mechanism for accessing objects across the boundary. Otherwise, however, in this impl, no truly shared objects.

@ljharb

ljharb commented Nov 13, 2026

Copy link
Copy Markdown
Member

OK - last question, I think :-) the RPC mechanism; does that allow two threads to mutate the same object at the same time?

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rlgtm, this is a good first step and addition to Node

@glenjamin

Copy link
Copy Markdown
Contributor

@glenjamin:

How many of the benefits are inherent to what green-threads can do, and how many of them are things that could conceivably be added to the existing workers implementation?

The benefits realized here are because they are not implemented the way existing workers are. Specifically, a green thread is not bound to a single physical thread the way a worker thread is. A green thread does not have an entire Node.js Environment associated with it. It doesn't have the full set of globals. And so forth. That is, we get the benefits here by subtracting from existing workers implementation and not adding to it.

What I meant is: is it feasible to allow choosing to subtract those features from workers piecemeal?

ie. Could the RPC thing be made available to workers? Could workers have a flag to get a limited environment? or the CPU/memory limits etc etc

I appreciate the M:N aspect is specific to green threads, but naively the other features appear to be choices made while implementing this.

@jasnell

jasnell commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

...is it feasible to allow choosing to subtract those features from workers piecemeal?

Not without essentially reproducing what I have here already. It would end up being about the same but with more effort required to ensure we don't break anything.

@jasnell

jasnell commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

@ljharb:

does that allow two threads to mutate the same object at the same time

It's still serialized safely in the receiving side. There won't be thread safety issues

@devsnek

devsnek commented Nov 13, 2026

Copy link
Copy Markdown
Member

This is really neat. I would be interested to see a comparison to building a pool of n worker threads and having them use a vm api to manage the isolates.

@jasnell

jasnell commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

@devsnek .... Here's the comparision for a pool of 8 workerthreads (the same size as the green thread pool), with tenants spread across them as vm contexts and called through script.runInContext(), with no pointer compression:

tl;dr As one should expect, the pool of vm contexts wins on raw performance but loses the isolation between them; in particular, since they all share an Isolate, the IsolateGroup under pointer compression means every context is within the same 4GB cage. So it's a deliberate trade off. Green threads aren't meant to replace the vm contexts.

Details

Setup

  • 88 CPUs, Linux x64. Two builds: the default Release build, and one with pointer compression, which supports isolate groups.
  • Green threads: one per tenant, on the shared pool of 8 threads. By default each is in its own isolate group (pointer-compression build only). "Shared group" means all of them in one IsolateGroup.
  • vm pool: 8 workers (the same size as the green thread pool), or 88 (one per CPU), with tenants spread across them. Each tenant is a vm context, and requests run with script.runInContext(). "timeout" means runInContext(context, { timeout: 50 }), which a host needs to stop tenants that loop.
  • Warm: for green threads, setWarmPoolSize(n), which creates isolates in advance. For the vm pool, each worker creates spare contexts in advance. Preparation isn't timed, but its memory is counted.
  • Each scenario runs in a fresh process. Single runs, so treat differences of a few percent as noise.
  • Benchmark: green-vs-vm-pool.js

Startup and memory (1000 tenants)

Release build

Tenants per second RSS per tenant Preparation (not timed)
Green threads, cold 747 5.2 MB –
Green threads, warm 48,245 5.2 MB 2,649 ms
vm pool, 8 workers, cold 10,122 0.25 MB –
vm pool, 8 workers, warm 96,239 0.25 MB 92 ms

Update: The memory measurement here in for green threads is off (too high) by about 1.3mb each. It's only about 3.86 MB per.... essentially the cost of an Isolate.

Pointer-compression build

Tenants per second RSS per tenant Preparation (not timed)
Green threads, cold 1,141 2.9 MB –
Green threads, warm 50,095 2.9 MB 1,610 ms
Green threads, shared group, cold 1,452 1.1 MB –
vm pool, 8 workers, cold 9,972 0.16 MB –
vm pool, 8 workers, warm 98,729 0.16 MB 90 ms

The vm pool wins clearly on density and startup, cold or warm. A context costs 7–20× less memory than a green thread, depending on the build and isolate-group setting. Warm vm contexts start about 2× faster than warm green threads, and take about 90 ms to prepare against 1.6–2.6 s. The warm green thread pool only applies to the default options, so it can't be combined with a shared group.

Throughput (1000 tenants, 50k requests, 64 at a time)

Release: requests/s Release: p99 Pointer compression: requests/s Pointer compression: p99
Green threads 139k 1.8 ms 140k 1.8 ms
Green threads, shared group – – 142k 1.9 ms
vm pool, 8 workers 151k 0.9 ms 136k 0.9 ms
vm pool, 88 workers 136k 1.0 ms 128k 1.2 ms
vm pool, 8 workers, timeout 81k 2.3 ms 82k 3.5 ms
vm pool, 88 workers, timeout 60k 2.8 ms 58k 3.1 ms

Without timeout, throughput is about equal: the vm pool is slightly ahead in the Release build and slightly behind with pointer compression. The vm pool has a lower p99. A host running untrusted tenants needs timeout, though, which costs 40–55% of throughput, because each call starts a watchdog. With it, green threads are about 1.7× faster.

When one of 100 tenants misbehaves

The vm pool uses 8 workers and timeout: 50; green threads use maxTaskCpuTimeMs: 50. "Others" are the other 99 tenants, which keep sending requests for 300 ms. Release build, with pointer-compression results in parentheses where they differ.

Problem Stopped after Tenants lost Others' requests in 300 ms Others' slowest request
Synchronous loop Green threads 51 ms 1 45k (44k) 3 ms (8 ms)
vm pool 50 ms 0 17k 51 ms
Microtask loop Green threads 52 ms (55 ms) 1 45k (44k) 3 ms (6 ms)
vm pool 102 ms, by killing the worker 13 13k 16 ms (14 ms)
vm pool, microtaskMode: 'afterEvaluate' 50 ms 0 18k (17k) 51 ms
  • Synchronous loop: both stop it after 50 ms. In the vm pool, the other tenants on its worker wait for the whole 50 ms, and the pool serves about 40% as many requests in the meantime.
  • Microtask loop: timeout doesn't cover microtasks that run after the call returned. The only way to stop the loop is to kill the worker, along with the 12 other tenants on it. microtaskMode: 'afterEvaluate' brings microtasks under timeout, but has pitfalls of its own: promises created outside the context aren't drained with it.
One tenant fills its heap Stopped after Tenants lost Others still answering
Green threads (maxMemoryMb: 64) 479 ms (1,413 ms) 1 99
vm pool (workers with maxOldGenerationSizeMb: 64) 434 ms (1,046 ms) 13 87

vm has no per-context memory limits, so the worker runs out of memory and dies, taking all its tenants with it.

Summary

It's a density versus isolation trade-off:

  • A vm pool wins on density and startup, cold or warm, by 7–20× on memory and about 2× on warm startup. Throughput is about equal without timeout.
  • Green threads win when one tenant can affect the others.
    • Each tenant has its own heap and its own CPU and memory limits.
    • Tenants can't stall each other, and nothing needs a timeout on every call. With timeout, green threads are about 1.7× faster.
    • A failure takes down one tenant, not a whole worker's worth.
  • vm isn't a security boundary, as its docs say. All the tenants on a worker share an isolate, so an escape from one context exposes the others and the worker's Node.js APIs. Each green thread is a separate isolate with no Node.js APIs, in its own isolate group by default.

For many trusted, well-behaved tenants, a vm pool is the cheaper choice. For untrusted ones, green threads give per-tenant isolation without paying a worker per tenant.

@jasnell

jasnell commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Just more on the approach here... looking at the isolation/sandboxing characterstics here... Assuming the V8 isolate boundary holds, so no V8 bug lets code escape its isolate... (most of this AI written with tweaks)

Details
Worker thread vm context (in a worker or the main thread) Green thread
Boundary None for code: same process, full Node.js A separate global object in a shared isolate. Explicitly not an isolation boundary A separate isolate, no Node.js or system access via API
What untrusted code can reach Everything the process can: fs, network, child processes, env vars, native addons Whatever leaks from the host realm, and through the usual leaks the host's full Node.js Only what the host passes: env, RPC stubs, modules, ports (Capability-based model)
Escape without a V8 bug? Not needed, it already has everything Yes, through well-known JS techniques. vm isn't a security mechanism, by its own docs No: no object graph is shared
CPU limit per tenant No, only wall-clock terminate() timeout, synchronous code only by default Yes: maxTaskCpuTimeMs, maxCpuTimeMs
Memory limit per tenant JS heap only, not ArrayBuffers None, shares the worker's heap Yes, heap and ArrayBuffers together
What a crash or out-of-memory takes down That worker Every tenant on the worker (or the main thread) That tenant
Can one tenant stall others? No (own thread) Yes, everyone on the same worker Not for longer than the CPU limit

Workers aren't a sandbox

A worker runs with the whole process's authority. The permission model applies to the whole process, so it can't restrict one worker. With fs, a worker can even read /proc/self/mem, which exposes every other thread's memory. The isolate boundary only helps against code that doesn't use Node.js's APIs, and a worker always has them.

vm contexts can be escaped without a V8 bug

All contexts on a worker share one isolate, so objects cross between them, and any host-realm object reachable from the sandbox is a way out. For example, this.constructor.constructor('return process')() reaches the host's Function constructor through the sandbox object. The same applies to host functions or objects passed in, and to errors and promises the host creates. These are JavaScript semantics, not V8 bugs. Hardening it means wrapping everything that crosses over, which vm2 tried and repeatedly got wrong. A successful escape lands in the worker's full Node.js environment, along with the other tenants on that worker.

Green threads only have what the host passes in

No JS object is ever shared:

  • Messages, env values and RPC arguments are structured clones, built in the receiver's own realm. There's no host prototype chain to climb.
  • Functions and RpcTargets become stubs. Calls are checked against an allowlist of method names on the side that owns the object. constructor, and anything from Object.prototype, Function.prototype or RpcTarget.prototype, is excluded.
  • Errors that reach the host are rebuilt from data properties only. No getters run, and no green-side code runs on the host.

The attack surface is the host's own env functions and RpcTargets. They receive untrusted arguments, so they must validate them like any server handler, and must not act as a confused deputy.

Isolate-group settings

  • Own group (the default where supported): each tenant has its own 4 GB pointer-compression cage, and can't use up heap space that others or the main thread need.
  • Shared IsolateGroup: tenants share a cage. Without maxMemoryMb, one tenant can exhaust it for the others. That's a denial-of-service risk, not a data leak.
  • isolateGroup: 'default': the cage is shared with the main thread and workers, so a tenant without a memory limit can starve the host.

Against V8 bugs, which are outside this comparison, separate groups also limit how far a heap-corruption bug can reach.

What remains for every option

  • Side channels. Everything shares one process and address space, and isolates, contexts and workers aren't a Spectre boundary. Passing tenants a SharedArrayBuffer gives them a high-resolution timer. Hostile code that might attempt timing attacks needs process isolation, or mitigations like coarse timers and no shared memory.
  • Denial of service against the host. Green threads limit CPU and memory per tenant, but don't rate-limit RPC calls or messages. A JIT-compiled loop that ignores termination (a known V8 bug) gets its isolate abandoned, and abandoned isolates are never freed, so a tenant that can trigger it repeatedly can leak memory. Workers hit the same bug, and there terminate() doesn't complete.
  • Host capabilities. Anything passed in, such as a database handle as an RpcTarget, or a port connected to a worker, is exactly as powerful as its host-side implementation.

In short

Workers give no sandboxing. vm contexts give isolation by convention, which ordinary JavaScript can break. Green threads give isolation by construction following a capabilities model: the only way out is through the capabilities the host passes in, or a V8 bug. In every option, defending against timing side channels takes process-level isolation.

@jasnell
jasnell force-pushed the green-threads branch 3 times, most recently from 6f21b2c to 4b6fe8b Compare November 14, 2026 17:19
@jasnell

jasnell commented Nov 14, 2026 •

Copy link
Copy Markdown
Member Author

I pushed a few more commits here to optimize performance and memory further.

Details are an AI generated summary... (slightly edited to remove slop)

tl;dr -- Compared with one worker per tenant, green threads use about 4.5× less memory (1.36 MB vs 6.17 MB PSS each), start about 4× faster cold (~3,700/s vs ~980/s), and reach 65,000–100,000/s from a warm pool. Message round trips are the same, and so is CPU-bound throughput at equal parallelism (with NODE_GREEN_THREADS_POOL_SIZE raised to match). Compared with a pool of workers running vm contexts, vm contexts are cheaper per tenant (0.25 MB and 15,000 cold starts/s on 8 workers, against 1.36 MB and 3,800/s), and raw request throughput is about the same (190,000 requests/s). But a host has to pass timeout to stop runaway tenants, which halves the pool's throughput, and timeout misses microtask loops unless the context uses microtaskMode: 'afterEvaluate'. A tenant that loops also delays its neighbours (52 ms vs 3 ms for the slowest other request), and one that fills its heap takes down every tenant on its worker. Green threads stop such a tenant in 50 ms with per-tenant CPU and memory limits and no per-call cost, without affecting anyone else. On top of that, they only have the capabilities the host passes in, while vm contexts aren't a security boundary.

Details

Updated comparison: green threads vs workers vs a pool of workers running vm contexts

Since the last update, green threads in V8's default isolate group start from a
small snapshot of their own instead of Node.js' snapshot. That brought one cold
start from ~3.6 ms to ~1.1 ms and memory from ~3.7 MB to ~1.3 MB per green
thread. The warm pool now also serves green threads with memory limits and
isolate groups.

Green threads vs one worker per tenant

Startup and memory, 1000 idle instances

starts/s PSS per instance PSS total OS threads
green thread 3,739 1.36 MB 1,364 MB 8 (shared pool)
green thread, from warm pool 80,778 1.38 MB 1,377 MB 8
worker 977 6.17 MB 6,171 MB 1,000

Pointer compression build:

starts/s PSS per instance
green thread, own isolate group (default) 2,556 1.35 MB
green thread, V8's default group 3,926 0.95 MB
green thread, one shared IsolateGroup 4,170 0.95 MB
green thread, from warm pool 101,977 1.36 MB
worker 960 4.85 MB

1000 isolated tenants, 50,000 requests

all started requests/s PSS total
green threads 271 ms 201,834 1,415 MB
workers 1,025 ms 157,475 6,216 MB

Message round trips, one instance: the same, 49,187/s vs 49,221/s (20.3 µs each).

CPU-bound tasks, 2000 × fib(27)

tasks/s
8 green threads 5,023
8 workers 5,052
88 green threads, NODE_GREEN_THREADS_POOL_SIZE=88 21,516
88 workers 22,230
one green thread per task (2000), pool of 8 4,151

At equal parallelism, CPU-bound throughput is the same. The pool size caps how
much JavaScript runs in parallel. It defaults to availableParallelism(), up
to 8, and NODE_GREEN_THREADS_POOL_SIZE raises it.

One of 100 tenants loops forever

stopped by stopped after others served in 200 ms
green threads maxTaskCpuTimeMs: 50 52 ms 46,332
workers terminate() after a 50 ms timer 65 ms 36,135

Green threads vs a pool of workers running vm contexts

(@devsnek's suggestion: N workers, tenants spread over them, one vm context
per tenant, requests run with script.runInContext().)

Startup and memory, 1000 tenants

tenants/s PSS per tenant prepared beforehand
green threads 3,781 1.36 MB –
green threads, warm pool 64,951 1.39 MB 394 ms
vm pool, 8 workers 15,360 0.25 MB –
vm pool, 8 workers, contexts created beforehand 121,545 0.25 MB 57 ms

Pointer compression build: green threads 2,439/s at 1.36 MB, in a shared
IsolateGroup 3,851/s at 0.96 MB, warm pool 69,346/s; vm pool 16,242/s at
0.16 MB.

A vm context is much cheaper than an isolate. It shares the worker's heap,
GC and V8 per-isolate structures, so cold starts are ~4× faster and memory per
tenant is ~5–8× lower. That's the price of the isolation below. About 360 KB of
each green thread (Release) is V8's per-isolate stub caches alone, which a
vm context doesn't pay.

1000 tenants, 50,000 requests, 64 at a time

requests/s p50 p99
green threads 186,481 0.32 ms 1.27 ms
vm pool, 8 workers 190,804 0.33 ms 0.72 ms
vm pool, 88 workers 169,638 0.36 ms 0.82 ms
vm pool, 8 workers, with timeout 80,415 0.63 ms 2.59 ms
vm pool, 88 workers, with timeout 58,469 1.00 ms 2.90 ms

Without a timeout, throughput is the same. But a host has to pass
runInContext()'s timeout to stop tenants that loop, and that more than
halves the pool's throughput (it starts a watchdog per call). Green threads
enforce CPU limits without a per-call cost.

One of 100 tenants runs a synchronous infinite loop

stopped after tenants lost others served in 300 ms slowest other
green threads 52 ms 1 (the bad one) 59,499 3 ms
vm pool, 8 workers, timeout: 50 51 ms 0 18,414 52 ms

One of 100 tenants runs an infinite microtask loop

stopped after tenants lost others served in 300 ms slowest other
green threads 54 ms 1 (the bad one) 61,776 3 ms
vm pool, timeout: 50 101 ms (worker terminated) 13 13,659 16 ms
vm pool, timeout: 50, microtaskMode: 'afterEvaluate' 51 ms 0 18,216 52 ms

timeout doesn't cover microtasks unless the context uses
microtaskMode: 'afterEvaluate'. Without it, the only way out is terminating
the worker, which takes every tenant on it along.

One of 100 tenants fills its heap

stopped after tenants lost others still answering
green threads 312 ms 1 (the bad one) 99
vm pool, 8 workers 284 ms 13 (whole worker) 87

In a vm pool, a tenant that loops blocks the other tenants on its worker until
it's stopped (slowest other request: 52 ms vs 3 ms). A tenant that exhausts the
heap takes down every tenant on its worker, since they share one heap.

Which benefits are inherent to green threads (@glenjamin)

Inherent, from one isolate per tenant on a shared pool:

  • A heap and GC per tenant: memory limits and out-of-memory only affect that tenant. A vm context can't have its own heap limit.
  • CPU limits per tenant without a per-call cost: they cover microtasks, and other tenants keep running on other pool threads.
  • One tenant can be terminated without affecting the others. In a vm pool, that requires terminating the worker.
  • No Node.js API surface by default: a green thread only has what the host passes in. vm contexts are not a security boundary (escapable without V8 bugs), and workers have full Node.js.
  • Cheaper than workers: about 4.5× less memory (1.36 vs 6.17 MB) and 4× faster cold starts, because there's no OS thread, event loop or Node.js environment per instance.

Not inherent, or where the alternatives win:

  • Memory and cold start per tenant: a vm context is cheaper, because it shares its worker's isolate. Most of a green thread's remaining 1–1.4 MB is V8's per-isolate overhead, which only V8 changes could reduce.
  • Raw request throughput: the same as a vm pool without timeouts, and the same as workers for CPU-bound work at equal parallelism.
  • Warm pools: they hide cold-start cost for green threads (65,000–100,000 starts/s), much like pre-creating vm contexts does for a pool.

@jasnell
jasnell marked this pull request as ready for review November 14, 2026 17:44
@jasnell jasnell added experimental Issues and PRs related to experimental features. large-pr PRs subject to the large-PR policy. labels Nov 14, 2026

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jasnell jasnell added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 14, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 14, 2026
@nodejs-github-bot

This comment was marked as outdated.

The time origin of events was set when the runtime was bootstrapped.
Green threads that start from a snapshot, or from the warm pool, got the
time the snapshot was made, or the isolate was initialized, so the
timeStamp of their events was too large.

Set it when the green thread starts instead, before anything else runs
in it. This also keeps the time out of snapshots, which must be
reproducible.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Green threads in isolate groups that only green isolates use started
from a snapshot created at runtime, which took about 10 ms the first
time a process needed it. Green threads in V8's default isolate group,
the only kind in builds without pointer compression, like the official
ones, ran the bootstrap of their runtime every time.

Create the snapshot for green-only groups in node_mksnapshot, and embed
it in the binary, in builds that support isolate groups. Add a context
in which the runtime is bootstrapped to Node.js' own snapshot, for green
threads in the default group. User-built snapshots don't have it, so
green threads started from them still run the bootstrap.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Green threads in V8's default isolate group, the only kind in builds
without pointer compression, started from Node.js' snapshot, with a
bootstrapped context added to it. Deserializing its isolate snapshot,
Node.js' startup heap, which green threads don't use, took about 75% of
the time it took to start them, and most of their memory.

Isolates in a group must only share the read-only snapshot. So create
a snapshot from V8's for them in node_mksnapshot, while the isolate
that created Node.js' snapshot still exists, so that the read-only heap
of the group is still Node.js'. The read-only snapshots then only differ
in a counter that V8 doesn't use when the read-only heap already
exists. Give the new snapshot Node.js' read-only snapshot, so that V8's
checks pass, and only use it if the main isolate uses Node.js'
snapshot. Remove the green context from Node.js' snapshot.

In a release build, this makes starting a green thread take 1.1 ms
rather than 3.6, and a green thread use 1.4 MB of memory rather than
3.7. Node.js' snapshot is back to its size before green threads.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
The pool that green threads run on has as many threads as the
available parallelism, but at most 8. That limits how many green
threads can run JavaScript at the same time: 256 green threads that
each run for 20 ms per request handle 400 requests per second on a
machine with 88 CPUs, and 4,205 with 88 pool threads.

Add an environment variable that sets the number of pool threads, up
to 1024, like UV_THREADPOOL_SIZE does for libuv's threadpool.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
SetIsolateCreateParamsForNode() queried the total and the constrained
memory, which reads files on Linux, even when the isolate's heap already
had a limit, and the result wasn't used. Workers call it twice, so every
worker read them at least once for nothing.

Only query them when the heap has no limit, and expose the query as
GetMemoryForHeapDefaults().

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Green threads without a limit for the old generation got V8's defaults
for the physical memory from NewIsolate(), which replaced the limit for
the young generation, so maxYoungGenerationSizeMb on its own had no
effect. Creating them also read /proc/meminfo and cgroup files each
time, about 2% of the time it took to start them concurrently.

Configure the defaults before setting the young generation limit, the
way workers do, with the memory queried once per process. Report the
heap spaces in __greenThreadInfo(), for tests.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Only green threads without memory limits, in the default isolate
group, could use the warm pool, since those are fixed when an isolate
is created. Hosts that run untrusted code usually set limits, so their
green threads always started cold.

Let setWarmPoolSize() take the isolateGroup and resourceLimits options
of new GreenThread(), and keep a pool for each isolate group and set of
memory limits it was called with. Green threads only use the pool for
theirs, so they get exactly the limits they would get without it. CPU
time limits are applied when green threads start, so they don't
matter.

With maxMemoryMb set, 1000 green threads, 64 at a time, start at about
60,000/s from a full pool rather than 4,100/s in a release build.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
V8 serializes external strings as ordinary strings unless their
resources are external references. The snapshots of green threads only
had the runtime's callbacks as external references, so they contained
copies of the sources of its builtins, about 65 KB, which every green
thread deserialized into its heap.

Add Node.js' external references, which include the sources of all
builtins, so that the snapshots refer to the sources in the binary.

This makes each green thread use 60 KB less memory (1.34 MB rather than
1.40 in a release build) and the startup snapshots 65 KB smaller.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Format the code with clang-format, and declare the V8 names that
src/node_green_thread.cc uses with using-declarations at the top of the
file rather than qualifying them with v8::. Remove an unused declaration
and keep all of the file's using-declarations sorted, as
tools/checkimports.py requires.

Regenerate doc/node.1, which was missing the updated description of
NODE_GREEN_THREADS_POOL_SIZE.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
SnapshotBuilder::CreateSnapshot() built the startup snapshot of green
threads in the default isolate group for every snapshot without a
builder script, including the ones that embedders create through
CommonEnvironmentSetup::CreateSnapshot(). Embedders have platforms of
their own, so per_process::v8_platform has none and creating the
snapshot crashed.

Build it only for GenerateAsSource(), which is its only user.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Green threads could only send messages to one receiver at a time.

Add BroadcastChannel to green threads, for the names in the new
broadcastScopes option of new GreenThread(). The channels are Node.js'
own, process-wide, so messages reach every BroadcastChannel with the
same name, in the main thread, in workers and in other green threads.
Other names throw ERR_GREEN_THREAD_BROADCAST_SCOPE, so green threads
can only use the channels that their host allows.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Green threads that ignored termination and were abandoned kept their
ports and BroadcastChannels open. The ports they were entangled with
were never closed, and messages for them queued up until the process
exited.

Disentangle the ports of green threads when they are abandoned, and drop
their messages. Since the green thread may still be running, the ports
are only entangled, disentangled and used to post messages while a lock
is held, which is never held while JavaScript runs.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Green threads could only be terminated, which interrupts whatever they
are doing.

Add greenThread.close([options]), which calls the green thread's
onclose function, and makes it exit with exit code 0 once nothing that
it waits for is pending: timers, RPC calls in either direction,
evaluations, its main module, and tasks queued before. Messages posted
after close() are dropped, and evaluate() rejects with the new
ERR_GREEN_THREAD_CLOSING. If the green thread hasn't exited within
`timeoutMs`, 5000 by default, it is terminated.

Assisted-by: Claude Opus 5.5
Signed-off-by: James M Snell <jasnell@gmail.com>
Functions, RpcTargets and AbortSignals in an RPC message were exported
while the message was serialized. If a later value in it couldn't be
cloned, such as a Symbol, the message wasn't sent, but its exports were
kept, along with the listeners of its signals, so the objects stayed
alive until the green thread exited.

Serialize the message first, keeping only the indices of its RPC
objects, and then make their descriptors with exportHostObjects(), which
doesn't change any state. The objects are exported once nothing can fail
anymore.

Assisted-by: Claude Opus 5.5
The side that receives an AbortSignal through RPC only held it weakly,
and Node.js doesn't keep signals alive for their listeners. A signal
that only its listeners referred to could be collected before its abort
arrived, which then went to a signal that no longer existed, so
listeners waiting for it never ran.

Keep imported signals until they abort, or the green thread exits.
Signals that never abort are now kept until then, along with their
originals.

Assisted-by: Claude Opus 5.5
With the permission model, green threads could be started without any
permission, while workers need --allow-worker.

Add a permission of their own, rather than reusing --allow-worker:
workers run a full Node.js environment, which is why --allow-worker can
undo the permission model, but green threads only have what their host
passes them. Without --allow-green-threads, new GreenThread() and
setWarmPoolSize() throw ERR_ACCESS_DENIED. The scope is 'green-thread',
for process.permission.has() and drop(), and its audit channel is
node:permission-model:green-thread. Unlike --allow-worker, it emits no
SecurityWarning.

Assisted-by: Claude Opus 5.5
Green threads that spin until another green thread does something, for
example on a SharedArrayBuffer, stall if they keep all pool threads
busy, as the green thread that they wait for never runs. A green thread
that keeps a pool thread busy also delays the timers of other green
threads on that thread.

setStallPolicy() makes the watchdog thread detect stalls: work that
waits for a pool thread while each pool thread that could run it has
run a single task for at least `timeoutMs`. It first adds up to
`extraThreads` pool threads, if the work can run on any of them, and
otherwise reports the green thread whose task has run the longest, to
the 'stall' listeners of its GreenThread or to the policy's `onstall`,
which can terminate it or give it more time. Stalls are reported one at
a time, and `fallbackAction` applies if the host doesn't decide within
the timeout, for example because its event loop is blocked. Green
threads that are terminated for stalling emit ERR_GREEN_THREAD_STALLED.

Refs: nodejs#67288
Assisted-by: Claude Opus 5.5
Recommend waiting without blocking, for example with a lock built on
Atomics.waitAsync(), which can't stall the pool, and describe which
deadlocks setStallPolicy() detects. Deadlocks that more pool threads
wouldn't help with, such as two green threads that each hold a lock
that the other one waits for, are not detected, and are stopped by
maxTaskCpuTimeMs instead.

Assisted-by: Claude Opus 5.5
@jasnell

jasnell commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Ok, I've updated to address the deadlock/stall issue and updated docs to match.

@Flarna:

Are native addons working on green threads like in workers? Clearly using thread locals there in JS thread might result in surprised but besides that?

Currently, no. Native addons are intentionally not enabled.

What about APIs like PerformanceNodeTiming holding uv details. Who do they behave? Are there any limitations in v8 built-in features like CpuProfiler, Inspector,...?

These currently are not supported, intentionally. New capabilities will be added carefully and case-by-case with extremely careful benchmarking and testing.

@jasnell

jasnell commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

This PR is already quite large. Since it's experimental, any additional work will be pushed to follow ups.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@jasnell jasnell added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Nov 16, 2026
Comment thread doc/api/green_threads.md
## RPC

A green thread can only use what its host passes it. Besides messages, the
host can give it an `env` object whose functions the green thread can call,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not call this env to avoid confusion with process.env or env in worker threads

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep... I just have no idea what alternative it should be. Please suggest colors for the bikeshed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a scope? 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided?

@bricss bricss Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provision?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about rpc?

Comment thread doc/api/green_threads.md
put: (key, value) => { store.set(key, value); },
},
newCounter: () => new Counter(),
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these seems sync on this side but async on the other. Can you clarify?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep... with the RPC mechanism, on the calling side everything is async. The call needs to be wait for the lock to be held.

Comment thread doc/api/green_threads.md
filename: 'file:///app/main.js',
modules: {
'file:///app/scale.js': 'export const scale = (x) => x / 2;',
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is very awkward, and would result in differences in module resolution.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, needs to be designed better. Open to suggestions. Not 100% happy with this as is. I'd like the principle to remain the same tho.

Comment thread doc/api/green_threads.md
* Modules are taken from `modules`, by URL, and otherwise from the `load`
hook.

The hooks run on the host's thread, and may be asynchronous. They are called

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add an examples for this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do, but will likely do so in a follow up PR. this one is massive already and I'm hesitant to add more to it.

// Event, EventTarget, AbortSignal and AbortController for green threads.
// There is no DOM tree, so events are only ever dispatched to their target.
// Node.js' own implementation depends on too much of Node.js to run in a
// green thread.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really prefer to not have to duplicate this. Also: what about WPTs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As would I but the current implementation is rather... heavyweight. It brings in a lot more than what is strictly needed and bloats the implementation. This is precisely why this PR does not bring in any other core APIs like URL or TextEncoder. We need to rethink a bit how those are defined to provide an absolute minimal runtime for these.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could create a lot of edge cases between the two implementations of EventTarget (what happens if you dispatch an event from one in the other) and I suspect is a big footgun especially for llms.

It would be preferable to decompose the implementation (is it bloated to be compliant or just mistakes we made?)

Comment thread doc/api/green_threads.md
[`--experimental-green-threads`][] flag is used.

```mjs
import { GreenThread } from 'node:green_threads';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a new module? Why not

Suggested change
import { GreenThread } from 'node:green_threads';
import { GreenThread } from 'node:worker_threads';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's one of the things to discuss I think. I intentionally didn't make it worker_threads yet because I wanted to avoid the potential confusion. These aren't worker threads so wasn't sure if it made sense there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, worth discussing indeed, I feel we should resist having two top-level modules which that much overlap, at least so the documentation ends up on the same page. Other alternatives to consider:

  • add node:worker_threads/green
  • move/alias worker_threads to node:threads/worker, and add node:threads/green

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👆

As in #67157, the standard library should move toward namespacing common concepts under umbrella terms. node:threads/<thing> is the right approach.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern there is that node:worker_threads is extremely entrenched at this point.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So was new Buffer().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we still find uses of that all over ;-) ... I'm not against the re-org, we just need to accept that it's won't be super clean.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accept it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with James here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So node:worker_threads/green?

@benjamingr benjamingr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RS as experimental let's ship this and get feedback!

Comment thread doc/api/cli.md
added: REPLACEME
-->

> Stability: 1 - Experimental

@marco-ippolito marco-ippolito Nov 20, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Stability: 1 - Experimental
> Stability: 1.0 - Early development

We should use the new experimental status:

@github-actions github-actions Bot removed the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts with its base branch, removing the author ready label.
Please rebase your branch onto the latest base branch, resolve the conflicts locally, and force-push.
Afterwards the pull request needs a fresh collaborator approval, and a collaborator will add the label back once it is author ready again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Issues and PRs related to experimental features. large-pr PRs subject to the large-PR policy. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.