Mixed Blocks: Storing More Fields Flat
summary
Extends OCaml’s runtime to allow mixed blocks where some fields are stored flat (numeric payloads inline) while the GC scans a prefix only, encoded by stealing one header bit to record scan-prefix length (supports up to 255 scanned words). Implemented in Jane Street’s flambda-backend branch, it keeps object size unchanged, supports int64/int32/float/nativeint, and yields modest real-world speedups (~1–2%). Trade-offs: unscanned fields must be a suffix and it disables generic comparison.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:50Memory layout vs performance
- 2:31OCaml value representation
- 4:40Mixed blocks concept
- 6:05Limitations of current garbage collector tags
- 7:08Mixed blocks design
- 8:34Header word encoding
- 10:21Scan prefix advantages
- 12:30Mixed blocks limitations
- 13:54Comparison & generic ops
- 14:37Explicit mixed blocks syntax
- 16:25Microbenchmarking
- 17:06Indirection impact
- 17:27Non-scanned fields
- 18:10Q&A
