ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.61k stars 400 forks source link

[rfc] Support per-process catapult trace information #3449

Open ejgallego opened 4 years ago

ejgallego commented 4 years ago

As discussed in the meeting, it would be great to allow --trace-file to collect timing information provided by sub-processes, for example, OCaml could provide information about time spent in each phase or Coq could provide information about time spent in proofs.

I think there are two design choices to make:

Thoughts?

Related issues:

rgrinberg commented 1 year ago

Just discussed this with Andrey and Pierre, and there's a definitely some demand for this feature. Here's a simple design that might work:

Whenever --trace-file is set:

  1. dune will create a temporary directory for every action
  2. It will set the path toDUNE_TRACE_FILE to this directory
  3. Once the action executes, dune will collect all the files in that directory and them to the trace.

@snowleopard how does that sound?

snowleopard commented 1 year ago

@rgrinberg Sounds good but I don't follow this bit:

  1. dune will create a temporary directory for every action

We don't need a separate directory for every action. A single directory (say, _build/.trace) should be sufficient, right? Then, for every action we set DUNE_TRACE_FILE=_build/.trace/<action_digest> so that the action can write to it.

rgrinberg commented 1 year ago

We don't need a separate directory for every action. A single directory (say, _build/.trace) should be sufficient, right? Then, for every action we set DUNE_TRACE_FILE=_build/.trace/ so that the action can write to it.

In my scheme, I allow for subcomponents of a particular action to write their own metrics as well. For example, if we run a ppx action, and different passes of the rewriter want to emit their own metrics - they're allowed to do so without worrying about the file being written to concurrently from somewhere else.

snowleopard commented 1 year ago

I see, that makes sense. What I'd like to avoid is the need to eagerly create that directory for every action, even though most of them don't need it (at least at first). Do you think we can require the actions that want to produce custom traces to mkdir that directory?

rgrinberg commented 1 year ago

I'm personally not worried about it as we create a ton of directories in dune builds and they never show up as overhead. Though allowing the actions to create them sounds fine as well to me.