Skip to content
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

Combine lambdas in OCaml output #894

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

elegios
Copy link
Contributor

@elegios elegios commented Jan 15, 2025

This PR uses syntactic sugar in OCaml to write, e.g., let f = fun a -> fun b -> ... as let f a b = ..., and similarly for merging anonymous functions. This has some benefits:

  • Reduces whitespace, before we would indent one level per let and fun, now just once for let.
  • Shorter code, might be easier to read.
  • After switching from dune to ocamlfind (Use ocamlfind instead of dune in compile.mc #873) I eventually found that backtraces in gdb had every function named as just fun, i.e., it only saw anonymous functions. I have no idea how the two tools invoke ocamlopt differently to get that effect, but merging arguments like done in this PR recovers a useful backtrace.

@elegios elegios force-pushed the combine-lambdas-ocaml branch 2 times, most recently from 992fc86 to 0bb4d0c Compare January 21, 2025 15:20
@elegios elegios force-pushed the combine-lambdas-ocaml branch from 0bb4d0c to 932b40b Compare January 21, 2025 15:55
@elegios
Copy link
Contributor Author

elegios commented Jan 21, 2025

We concluded during the meeting we wanted to see how this might impact performance. Here's the bootstrapping process before:

 2) [163.162s] [build] src: ./boot eval main/mi-lite.mc -- 0 main/mi-lite.mc ../build/src/mi-lite        
 1) [49.822s] [build] src: ./mi-lite 1 main/mi.mc ../build/src/mi1                                       
 0) [50.277s] [build] src: ./mi1 compile main/mi.mc --output ../build/src/mi 

and after:

 2) [153.074s] [build] src: ./boot eval main/mi-lite.mc -- 0 main/mi-lite.mc ../build/src/mi-lite        
 1) [31.709s] [build] src: ./mi-lite 1 main/mi.mc ../build/src/mi1                                       
 0) [31.805s] [build] src: ./mi1 compile main/mi.mc --output ../build/src/mi

I've done a few runs, and the first step seems to be roughly equal time taken in the two versions, while step 2 and 3 seem to consistently go from ~50s to ~30s, which is... weird, to put it mildly. The intermediate .ml file that's passed to ocamlopt goes from 33MB to 25MB.

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.

1 participant