Skip to content

Commit bfd27fb

Browse files
committed
doc(action-plugin): describe single-process staging
Remove the stale warning that every nontrivial stage respawns the plugin and therefore makes linear bind chains quadratic. Document that Dune now builds dependencies between stages while preserving the running plugin process, and that each dynamic-run invocation starts the program only once. Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
1 parent accf344 commit bfd27fb

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

doc/reference/actions/dynamic-run.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ dynamic-run
88
Execute a program that was linked against the ``dune-action-plugin`` library.
99
``<prog>`` is resolved in the same way as in :doc:`run`.
1010

11+
The program remains running while Dune builds dependencies that it discovers,
12+
so each ``dynamic-run`` invocation starts the program only once.
13+
1114
Example::
1215

1316
(dynamic-run ./plugin.exe)

otherlibs/dune-action-plugin/src/dune_action_plugin.mli

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,9 @@ module V1 : sig
88
dependencies of a computation. Dependencies can be declared dynamically -
99
the list of dependencies can depend on previous dependencies.
1010
11-
Note: Monadic "bind" is provided, but it can be very costly. It's called
12-
[stage] to discourage people from overusing it. When dune decides that the
13-
action needs to be re-run, it runs (nontrivial) stages one by one, and
14-
starts a process from scratch for every stage. So a linear chain of binds
15-
leads to a linear number of program re-runs, and therefore overall
16-
quadratic time complexity. This also means that using non-deterministic
17-
mutable state can lead to surprising results. (note that with the current
18-
implementation, nontrivial stages are those that have some dependencies,
19-
so a stage that merely writes out some targets is "free") *)
11+
Monadic "bind" is called [stage] to make dynamic dependency boundaries
12+
explicit. Dune builds the dependencies of each stage while keeping the
13+
plugin process running, then resumes the computation in that process. *)
2014

2115
module Path = Path
2216

@@ -40,8 +34,8 @@ module V1 : sig
4034
[stage a ~f] is a computation that is equivalent to staging computation
4135
[bt] after computation [at].
4236
43-
Note: This is a monadic "bind" function. This function is costly so
44-
different name was chosen to discourage excessive use. *)
37+
This is a monadic "bind" function. The name highlights that dependencies
38+
introduced by [f] are discovered in a later stage. *)
4539
val stage : 'a t -> f:('a -> 'b t) -> 'b t
4640

4741
(** {1 Syntax sugar for applicative subset} *)

0 commit comments

Comments
 (0)