Skip to content

Propagate arity between compilation units #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 19, 2025
Merged

Propagate arity between compilation units #1594

merged 13 commits into from
Jun 19, 2025

Conversation

hhugo
Copy link
Member

@hhugo hhugo commented Apr 8, 2024

Fixes #550

  • Store immutability property of blocks
  • Try to recover some immutability info from debug events. (currently assuming modules are immutable.
  • Use this info to compute an approximated shape for registered globals.
  • Use shape info to compute function arity across compilation units
  • Shapes are currently written as special comments (//# shapes:) inside the generated js and can be read back if explicitly requested (with the --load-shape FILE.cma.js)

TODOs:

  • check the behavior with recursive modules
  • fix with effects
  • update global_flow ?
  • better mechanism for shape propagation ?-
  • store shape in a different file ? yes no, adding support in dune was too annoying.
  • should the "shape" file be given jsoo on the command line or should it look for it on the file system ? both loading shapes need to be explicit.
  • update dune rules with additional deps (Jsoo shapes ocaml/dune#10767)

@hhugo hhugo requested a review from vouillon April 8, 2024 09:59
@hhugo
Copy link
Member Author

hhugo commented Apr 8, 2024

@vouillon, feel free to comment, review and even commit the branch.

@hhugo hhugo force-pushed the shapes branch 2 times, most recently from ffe3e43 to c7c009b Compare April 18, 2024 07:58
@hhugo hhugo force-pushed the shapes branch 3 times, most recently from ce02188 to f8138d0 Compare July 26, 2024 12:12
@hhugo hhugo mentioned this pull request Jul 26, 2024
@hhugo hhugo force-pushed the shapes branch 3 times, most recently from b17b2f0 to 1ed2368 Compare October 26, 2024 06:45
@hhugo hhugo force-pushed the shapes branch 2 times, most recently from 14fe546 to 3821d45 Compare November 7, 2024 09:37
@hhugo hhugo marked this pull request as ready for review November 19, 2024 14:35
@hhugo hhugo changed the title PoC: Propagate arity between compilation units Propagate arity between compilation units Nov 19, 2024
@hhugo
Copy link
Member Author

hhugo commented Nov 19, 2024

@vouillon, I think we could merge this before we have the support merged inside dune.
Would you want to give it another round of review ?

@hhugo hhugo force-pushed the shapes branch 2 times, most recently from a160212 to 53d94b5 Compare November 21, 2024 16:24
@hhugo
Copy link
Member Author

hhugo commented Nov 22, 2024

It increases to the time to build the toplevel in whole program compilation by ~10%. But we don't benefit from shapes in such case.

@vouillon
Copy link
Member

The following command spends a lot of time in Flow.the_shape_of (called from Specialize.function_arity).

js_of_ocaml `which ocamlc.byte` 

@hhugo hhugo force-pushed the shapes branch 2 times, most recently from 99a19f4 to b3a69be Compare June 12, 2025 13:15
@hhugo hhugo added this to the 6.1 milestone Jun 12, 2025
@hhugo
Copy link
Member Author

hhugo commented Jun 13, 2025

@rickyvetter, the new/updated build rules should be much easier to integrate.
The PR now also works with wasm_of_ocaml.
More feedback/testing before merging would be nice. I'm planning to have this PR part of the next release.

@hhugo hhugo merged commit b8b75b9 into master Jun 19, 2025
26 checks passed
@hhugo hhugo deleted the shapes branch June 19, 2025 15:13
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.

Separate compilation: generate and use cross module information regarding function arity
4 participants