| layout | developer-doc | |||
|---|---|---|---|---|
| title | Execution Server Flow | |||
| category | runtime | |||
| tags |
|
|||
| order | 6 |
This document describes the API and workflow of the internal execution server.
The actionables for this section are:
- describe the
org.graalvm.polyglot.Context.Builder.serverTransportworkflow of connecting to the server.
The actionables for this section are:
- Document the server's API.
This section describes certain implementation details of the execution server, allowing it to perform its operations safely and interactively.
The execution server uses a job queue containing requests to be performed. An API method may queue multiple jobs.
There are a number of job types used internally for handling different scenarios:
Takes a set of module names that must be compiled and ensures that the
corresponding modules are compiled in the newest version. It also performs cache
invalidations on changes since the last batch. Caches should be invalidated for
all contexts affected by this recompilation. This operation is idempotent and
should be run before any Execute action. This operation is not currently
interruptible, but may become so in the future.
Takes a context ID and an optional set of expression IDs that should be executed. and executes the Enso code corresponding to the context's stack. Updates caches and sends updates to the users.
This operation is interruptible through Thread.interrupt().
EnsureCompiledjobs must be run sequentially (i.e. no other state modifications or executions are allowed during this job's run).Executejobs may be run in parallel with each other (but not withEnsureCompiledjobs).EnsureCompiledjobs may be collapsed into one, by unifying their module sets.Executejobs with the samecontextIdmay be collapsed into one, by merging theirexpression IDssets.- All enqueued
EnsureCompiledjobs should run before anyExecutejobs. - The order of
EnsureCompiledjobs can be freely changed by the compiler.
The following describes handling of API messages through job queue modifications.
- EditFile:
- Abort and/or dequeue all pending and running messages (if possible).
- Synchronously perform all code updates.
- Enqueue an
EnsureCompiledwith all affected files. - Enqueue an
Executefor each existing context.
- Stack Modifications and Recomputes:
- Abort and/or dequeue all pending and running requests relevant to the affected context.
- Synchronously perform all state updates.
- Respond to the user.
- Enqueue EnsureCompiled for the file at the bottom of the affected context's stack.
- Enqueue Execute for the affected context.
- Visualization modifications:
- Synchronously perform all state updates.
- Respond to the user.
- Enqueue
EnsureCompiledandExecutefor the affected context. Set the minimal set of expressions required to compute toSet(visualizedExpression)in theExecutecommand.
- Create/Destroy context:
- Abort any jobs concerning the affected context.
- Perform state updates / cleanups. No jobs to schedule.