Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purposes
This PR is a first draft to experiment with a typer domain, i.e., a dedicated domain that performs typing computations (partially) in parallel with the main domain, which manages the server and analyzes the results. The final implementation should also support:
Current Changes
For now, this PR introduces the following modifications:
Local_store
scope to support computations in both domains.Design Notes & Expected Changes
Laziness
As noted in the Lazy module documentation:
Since laziness is inherently unsafe in a multicore context, it has been removed. However, this introduces new bugs as some previously deferred computations now run eagerly:
local_store
scope must be carefully extended.These issues are not currently resolved.
Local Store Management
Most computation must take place when the
local_store
isbound
. Previously, all computations were enclosed withinLocal_store.with_store
(viaMocaml.with_state
). However, this approach is not compatible with computations involving two domains.To address this,
with_store
has been replaced withopen_store
andclose_store
, allowing more flexible management of the store’s scope.This design is likely to evolve further, particularly to enable proper interruption of the typer when needed.
Concurrency with the Typer Domain
Currently, concurrency is handled using atomic top-level values, which rely on active polling. This approach will likely be replaced (at least partially) with mutexes and conditions variables, allowing the domains to perform passive waiting instead.
Credits
This preliminary work was done with @voodoos and @xvw.