Skip to content

Improve incrementality of jsoo build#13612

Draft
vouillon wants to merge 1 commit intoocaml:mainfrom
vouillon:jsoo-incremental
Draft

Improve incrementality of jsoo build#13612
vouillon wants to merge 1 commit intoocaml:mainfrom
vouillon:jsoo-incremental

Conversation

@vouillon
Copy link
Member

Move #7389 on top of #13611.

Instead of compiling *.cma files to JavaScript. We can compile individual *.cmos to javascript and link all *.cmo.js together.
This results in a much better incremental build as jsoo no longer recompile compilation units that were not modified.

Linking *.cmo.js into a cma.js should be much faster than any compilation with jsoo.

This can only be done for local libraries as "installed" ones are not required to provide individual cmo. This is fine.

@hhugo
Copy link
Collaborator

hhugo commented Feb 13, 2026

Now that we have shape files, we have the option to use shape info from other cmo.js, like it's done with cmx. Should we support that, if yes, should it be under a config of some sort ? I would expect that generated code is less optimized with this PR because I think jsoo propagate shapes between compilation units when compiling a cma to js.

@vouillon
Copy link
Member Author

Now that we have shape files, we have the option to use shape info from other cmo.js, like it's done with cmx. Should we support that, if yes, should it be under a config of some sort ? I would expect that generated code is less optimized with this PR because I think jsoo propagate shapes between compilation units when compiling a cma to js.

From what I can see, this is already implemented. We are passing the appropriate dependencies to Jsoo_rules.build_cm.

@hhugo
Copy link
Collaborator

hhugo commented Feb 13, 2026

From what I can see, this is already implemented. We are passing the appropriate dependencies to Jsoo_rules.build_cm.

Cool, then the question is, do we want this to be the only way to do separate compilation or should we support a "faster" mode where we don't have these X-module deps ? Do we get identical cma.js with this PR or are we missing some information from shapes ?

rgrinberg pushed a commit that referenced this pull request Feb 18, 2026
Refactor jsoo archive generation to use a demand-driven approach.
Previously, rules for all configuration variants were generated upfront
whenever a library was built. This logic is now decoupled from general
library rules; instead, the build system intercepts requests for
specific configuration directories and generates the necessary rules
dynamically.

This will enable the following improvements:
-  The config details can be moved out of dune into jsoo (#13613).
- This will make it possible to implement a more incremental build
process without generating a large volume of unused rules for
unrequested configurations (#13612).

Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
Signed-off-by: Hugo Heuzard <hugo.heuzard@gmail.com>
Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
@vouillon
Copy link
Member Author

vouillon commented Mar 3, 2026

I think we should get the same information from shapes with this PR.

Shapes introduce a dependency between cmos. So, indeed, there could be a faster mode where cmos only depend on cmis. I'm not sure this is worth it, though.

@hhugo
Copy link
Collaborator

hhugo commented Mar 4, 2026

I think we should get the same information from shapes with this PR.

Shapes introduce a dependency between cmos. So, indeed, there could be a faster mode where cmos only depend on cmis. I'm not sure this is worth it, though.

Maybe we should try to bench compiation of libraries with this branch. Large and small libs. Fresh build and incremental ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants