docs/runtime/execution-server-flow.md
This document describes the API and workflow of the internal execution server.
<!-- MarkdownTOC levels="2,3" autolink="true" --> <!-- /MarkdownTOC -->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:
EnsureCompiledTakes 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.
ExecuteTakes 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().
EnsureCompiled jobs must be run sequentially (i.e. no other state
modifications or executions are allowed during this job's run).Execute jobs may be run in parallel with each other (but not with
EnsureCompiled jobs).EnsureCompiled jobs may be collapsed into one, by unifying their module
sets.Execute jobs with the same contextId may be collapsed into one, by
merging their expression IDs sets.EnsureCompiled jobs should run before any Execute jobs.EnsureCompiled jobs can be freely changed by the compiler.The following describes handling of API messages through job queue modifications.
EnsureCompiled with all affected files.Execute for each existing context.EnsureCompiled and Execute for the affected context. Set the
minimal set of expressions required to compute to
Set(visualizedExpression) in the Execute command.