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