Skip to content

Commit b4096a8

Browse files
committed
ocamlopt: use -linscan option
The OCaml native-code compiler has a register allocator which is well-known to take a long time in some pathological scenarios that are rare in human-written programs, but common in some computer-generated programs. The programs generated by this benchmark hit exactly this bad situation. The OCaml compiler also provides a linear-scan register allocator without a performance issue for such programs. It is not activated by default, but enabled as an option (`-linscan`) and users that hit this limitation with the standard register allocator are invited to use it. This commit passes the '-linscan' option to the native compiler (ocamlopt) to enable the linear-scan register allocator. On my machine, ocamlopt build time goes from 20s to 8s with this change. One could debate whether non-default options should we passed to get a representative benchmark, butin this case I think the choice is very reasonable: - A human user facing the same compile-time issue would be advised to pass this option. - The cost here comes from the benchmark generating code very different from idiomatic programs, which is arguably a limitation of the benchmark (and not of the compiler itself), so alleviating it with specific options seems reasonable.
1 parent 39e4df3 commit b4096a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

benchmark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ def benchmark_OCaml(results, code_paths, args, op, templated, bytecode):
802802
runner=([which('ocamlrun')] if
803803
bytecode else
804804
True),
805-
exe_flags=['-c'] if bytecode else [],
805+
exe_flags=['-c'] if bytecode else ['-linscan'],
806806
args=args,
807807
op=op,
808808
compiler_version=version,

0 commit comments

Comments
 (0)