melange-re / melange

A mixture of tooling combined to produce JavaScript from OCaml & Reason
https://melange.re
Other
841 stars 52 forks source link

Delay JS program optimizations in Lam_compile_main until JS generation #464

Open anmonteiro opened 1 year ago

anmonteiro commented 1 year ago

Might allow to build more things concurrently, which will improve the Dune build plan, as per https://github.com/ocaml/dune/pull/6698#issuecomment-1353258358

rgrinberg commented 1 year ago

Some criteria that we should use for delaying work to the .js generation step:

  1. The work should never raise. That is, all error checking should be done at the creation of the .cmj
  2. The work shouldn't have to do many look ups in the environment. Otherwise we'll need to reload the environment when generating the .js and that can be quite expensive. We'll also need to change the rules to include dependencies on said environment.

Aside from the rules above, we should delay as much work as possible.

ELLIOTTCABLE commented 1 year ago

Hm.

That is, all error checking should be done at the creation of the .cmj …

That seems concerning, unless there's no way for emitting a require to error? (thinking here in terms of virtual libraries, ocaml/dune#7104.)