Goldfirere
Showing 1–3 of 3 transcripts.
- Jane Street8 min
OCaml's New Proposed "include functor" Syntax | OCaml Unboxed
Jane Street is developing an "include functor" feature for the OCaml compiler that allows modules to directly include functor results based on their own preceding definitions. This innovation eliminates the need for cumbersome intermediate wrapper modules and manual reordering, streamlining the implementation of repetitive patterns like reverse array iteration. A working compiler version supporting this syntax is currently available for testing, with plans to upstream the feature to the mainstream OCaml distribution.
- Jane Street16 min
Pitfalls with Tail Calls and Locals in OCaml | OCaml Unboxed
Jane Street researchers developed a "local mode" for their OCaml compiler to optimize memory allocation on the stack, but discovered that standard tail call optimization causes "local value escapes" errors when recursive closures capture variables from a region that ends immediately before the call. To address this, the team introduced a "regional" sub-mode that permits specific values to escape one region boundary, allowing tail-recursive functions to maintain $O(1)$ stack space without explicit `non-tail` annotations, though passing these values through intermediate functions can strip this status and force $O(n)$ allocations. The developers acknowledge that current workarounds like explicit annotations or variable indirection are cumbersome for practical use, prompting a push for better compiler heuristics to automate safe tail calls in future upstream releases.
- Jane Street23 min
OCaml Locals Save Allocations | OCaml Unboxed
Jane Street demonstrates how a specialized OCaml compiler reduces memory allocation by introducing the `local` keyword, which restricts value lifetimes to specific function and loop regions. This approach requires replacing standard library functions like `list.iter` with custom implementations that explicitly label arguments as `local` to prevent value escapes, achieving a 50% reduction in word allocations in benchmark tests. Further refinements with the `exclave` keyword and strict type inference drive allocation overhead to near-zero, thereby minimizing garbage collection latency for the experimental feature planned for future upstream integration.