Skip to content

dune build -w restricting job number for no reason #5549

@Alizter

Description

@Alizter

Problem description

There seems to be an issue with dune build -w. It can be observably slow due to a restriction of jobs. This can be seen as slow, since stopping watch mode and doing a fresh dune build will be much faster. The issue seems to be during the rule finding phase.

Here is a demonstration GIF of this behaviour. Details of what is happening are below:

dune_build_watch_slowdown_rule_finding

  1. dune build -w is run, and it works as expected. Most of the time is spent rule finding, but due to cache and everything already being built, it finishes quickly.
  2. Next whilst watch mode is still running, an .ml file early in the dependency tree is changed, triggering a rebuild. Immediately you can observe the number of jobs drop to a low count. What is dune doing here?
  3. To demonstrate that this is an issue with watch mode, a fresh dune build is triggered, and as expected everything builds normally and quickly.

There are some key details with this setup. This is the main Coq repo being changed, and importantly there is ml code being edited which are later being depended on by dune Coq stanzas. Retrying the same test, but this time with the @check target (building only ml code) results in no observable slow down, leading me to believe that this is an issue with the interaction of rule finding and the Coq rules.

Reproduction

  1. Clone the https://github.com/coq/coq repo.
  2. Do dune build -w. This will take a while but once it starts building .v files (see from --display=short or --verbose) you can do the next step.
  3. Edit an ml file, for example kernel/declareops.ml, you can even drop let _hello = "world" inside.
  4. Observe that the rebuild will now restrict itself to a low job count.
  5. Stopping watch mode and rebuilding will speed up the build again.

Specifications

  • Version of dune (output of dune --version): 3.0.3
  • Version of ocaml (output of ocamlc --version) 4.12.1
  • Operating system (distribution and version): Ubuntu

cc @rgrinberg

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions