Memory allocation in OCaml and beyond
In this video I look into how memory allocation works in OCaml 4, how it is different from OCaml 5 (aka multi-core). I browse the source-code of OCaml runtime and do a bunch of experiments to demonstrate the behaviour of the allocator depending on the size of allocated objects. Finally, I show how the allocator behaviour on MacOS is different from that on Linux with an extra sprinkle of C++. Contents: 00:00 Intro 00:21 Context - Infer 01:11 Context - OCaml 02:19 Multi-core OCaml 03:11 Context - increased memory consumption with OCaml 5 04:23 Plan for the video 05:06 Memory allocation behaviour in OCaml 4 06:54 Memory allocation behaviour with OCaml 5 08:10 Disclaimer 08:41 Exploring OCaml 4 memory allocation 10:07 OCaml 4: allocating on minor vs major heaps 11:10 OCaml 4: continuing with the major heap allocation 12:18 Note on mmap vs malloc 13:51 OCaml 4: allocate + strace 14:39 glibc memory allocator 16:03 OCaml 5 and GC compaction patch 16:33 OCaml 5 memory allocation code 17:57 OCaml 5: pool vs large allocations on shared heap 20:02 OCaml 5: mmap vs malloc threshold 21:05 Setting up an opam switch with a custom OCaml compiler 23:01 Segfault happens 25:29 Running on MacOS... and nothing makes sense anymore 28:25 Dissecting the weirdness 29:36 C++ to rescue 31:24 MacOS memory under pressure 36:25 Outro Programs used in the video: https://github.com/artempyanykh/alloca OCaml GC compaction patch: https://github.com/ocaml/ocaml/pull/12193 OCaml 5 memory consumption topic on discuss: https://discuss.ocaml.org/t/ocaml-5-gc-releasing-memory-back-to-the-os/11293
Download
0 formatsNo download links available.