OCaml aims at overall performance in 4.10 release


General purpose programming language OCaml has landed in version 4.10, improving memory usage, garbage collection (GC) costs and more in the project used by Microsoft, IBM, CEA and others.

OCaml was developed in 1996 at the French national research institute for digital sciences, Inria, for use in applications involving symbolic computation such as compilers or program analysers. Its most highlighted features include a powerful type system, automatic memory management, and user-definable algebraic data types and pattern-matching.

In the current release, its creators have fitted OCaml with a multi-index variant of extended indexing operators, helping with the indexing of generic multidimensional arrays, for example. The new version also contains a function to ignore module expressions, and enforces safe immutable strings.

OCaml’s runtime system has been improved to work better with programs with large heaps. This has been realised by a still experimental best-fit allocator which is promised to reduce GC cost and memory usage, and can be set by putting OCAMLRUNPARAM=“a=2”. The runtime has also seen the addition of a C function to execute all pending actions inside long-running C functions, and fixes for its stack overflow detection and bytecode backtrace generation.

Further optimisations can be found in the standard library, for example, where they are meant to improve array construction and filling as well as the clearing of hashtables. The lib now also contains “Filename.quote_command to produce properly-quoted commands for execution by Sys.command”, “‘%#F’ modifier in printf to output OCaml float constants in hexadecimal” and tries to better avoid duplicate work when sorting lists.

Version 4.10 comes with quite a number of breaking changes, which is why a quick glance at the release notes is advised. Reasons why your old code might not work as expected once you made the jump range from the major garbage collection hooks no longer interacting with the OCaml heap, to allocation functions not triggering OCaml callbacks when called from C, to a new table for global variables in the runtime.