Elide/ Architecture

Architecture · threading

Many contexts, one engine.

Run independent tasks in parallel, call across languages on one thread, and reuse compiled code through a shared engine.

Walkthrough

Contexts and Engines

Elide runs independent execution contexts in parallel1 5. Each context owns its guest language state5.

Contexts support multiple languages

JavaScript and Python can exchange values within one context3 18. Host access and guest thread permissions are configured at the context level1 2.

Each language keeps its threading model

A context running JavaScript admits one executing thread at a time4 5. Python-only contexts support multiple threads, with a per-context GIL serializing Python execution and normally releasing around foreign calls6.

A bounded pool of reusable contexts

Elide schedules one active task per pooled context, with a configurable bound that defaults to processor count7 8. Reused contexts retain application state5 9. Tasks that require a particular context return to it10.

Callbacks return to their context

I/O and worker completions post work to the context's event loop12 13 17. Callbacks run on the thread holding that context and can call another language without a thread handoff11 5 6.

Dedicated workers for CPU-bound tasks

Each worker owns a dedicated host thread and a fresh context on the shared engine14 15. Workers exchange messages through structured clone16.

Shared engine with JIT caching

The shared engine reuses eligible parsed and compiled code across contexts20. GraalVM's Auxiliary Engine Cache can persist this code across program starts21.

Parallel requests, familiar semantics

For example, a server can distribute requests across pooled contexts8. Within a request, a Python handler can call a JavaScript renderer and use its result directly18 19.

threads
sockets
Host OS
Rust CLI
Rust · native
Truffle
compiled code
context pool
Engine · Native Image
engine / context
event loop
policy
active thread (JS)
Context · ×N
JavaScript
Python
Languages
request handler
React SSR
Application
Node · one processElide · one runtimeworker A JavaScriptworker B JavaScriptexplicit sharingshared bufferscontext A JavaScript + Pythoncontext B JavaScript + Pythoncode reuseshared engine TruffleRust CLI · parse --allow-threads off by defaultinvocation record Cap'n ProtoFFI
allowThreads · Bool
Engine entry @CEntryPointcontext builder thread creation on
Rust CLI · parse --allow-threads · off by defaultinvocation record Cap'n Proto · allowThreads BoolFFIEngine entry @CEntryPointcontext builder thread creation on
posted from other threads runs on the context's threadI/O completion file · socketworker message another contextDNS + DB completion adopted threadexternal queue post · unparkloop turn microtasks · external timerssetTimeout callback JavaScriptPython call same threadposted from other threads on the context's threadI/O completion file · socketworker message another contextDNS + DB adopted threadexternal queue post · unparkloop turn microtasks · external timerssetTimeout JavaScript callbackPython call same thread
context A JavaScript + Python one thread at a timecontext B Python only many threads · GILT1T2T3T1T2T3GIL
queue context pool bound: one context per processorcontext 1 freeTcontext 2 freeTcontext 3 not yet createdTtask 1task 2task 3task 4 · confinedtask 5
unconfined · any free context confined · pinned to one context
context policy
languages and capabilities configured together
worker_threads
one engine · one context per worker · structured-clone messages
one engine
shared code · AEC can persist specialization
Python and React
Python handler, React render, response, all on one thread.

Sources

  1. Elide runtime — Contexts share an engine and configure their guest capabilities.
  2. Elide context configuration — Runtime components apply language and capability settings to each context.
  3. Elide value sharing — Polyglot interoperation and value sharing between guest languages.
  4. GraalJS multithreading — Multiple JavaScript contexts can run in parallel; each context admits one executing thread at a time.
  5. Polyglot Context — Context access rules, language interoperation and shared-engine code reuse.
  6. GraalPy threading — A per-context GIL governs Python execution and releases around foreign calls according to the interop policy.
  7. Elide context pool sizing — The configurable pool bound defaults to available processor count.
  8. Elide task dispatch — Scheduling tasks onto available or designated contexts within the pool bound.
  9. Elide context reuse — Returning a context to the pool after task execution.
  10. Elide context affinity — Routing confined tasks to their designated context.
  11. Elide event-loop ownership — Callbacks execute on the thread holding their realm’s context.
  12. Elide external completions — Posting work to the context’s event loop and waking its owner.
  13. Elide asynchronous I/O — Routing I/O completions into the guest event loop.
  14. Elide workers — Dedicated host threads and fresh contexts on the shared engine.
  15. Elide worker creation — Creating a worker thread and context on the parent’s engine.
  16. Elide worker messages — Structured-clone payloads for communication between workers.
  17. Elide worker lifecycle — Posting worker notifications to the parent’s event loop.
  18. Elide Python interoperation — Evaluating JavaScript from Python within the same context.
  19. Python and JavaScript example — Calling JavaScript and reading its result from Python.
  20. Shared-engine code caching — Reusing eligible parsed and compiled code across contexts with compatible configurations.
  21. Auxiliary Engine Caching — Persisting syntax trees and optimized code for reuse by the same native executable.