"flambda for newbies" questions

jbuilder
flambda

#1

I see a lot about flambda but I’m not clear on its status and usage. I understand that flamba consists of compiler functions that are intended to provide better inlining and provide certain cross-module optimizations for native code compilation. That’s not very precise, but maybe it’s all that I need to know right now–I’m not sure.

I see that there’s an OCaml 4.05.0+flambda switch that’s separate from the default 4.05.0 switch. Why isn’t it part of the default compiler? Is flambda is still at an alpha or beta stage? Or is some skill is needed to know how to use it properly–maybe it can slow compiled code down if used without caution and understanding? Is it better for non-experts to use a compiler that doesn’t try to perform flambda’s optimizations?


#2

I think that’s because it increases compile time, but compiled code is faster when you use a lot of modules and functors (example with a speed up factor of 20). There has been amelioration since 4.03 but it may not be sufficient. You may find useful informations on this topic in this discussion on Jane Street blog.


#3

Thanks @kantian. That helps.

I suppose it would be ideal if the main current release page on ocaml.org include brief summaries of the differences between the 4.05.0 compiler releases. The changelog and annotated changelog referenced there are obviously potentially useful, but I think you have to be a little bit devoted to go through even an annotated if you have no idea what any of the non-default releases might be useful for. My natural tendency is to assume that whatever is the default must be good, and that those other compilers are for special cases that only experts care about. :slight_smile: But flambda sounds like something that could be very good for everyone (as long as they don’t mind longer compilation times–which isn’t trivial–I too have suffered from long compilation times with past work).


#4

Here’s another newbie question. I’ll try asking it here because it fits the title …

flambda ocamlopt flags such as -O2 and -O3 are supposed to affect the compilation across modules, but in jbuilder, I specify these flags in each jbuild file [like this, right? ` (executables (… (ocamlopt_flags “-O3”)))``]. Am I getting optimization across packages that have there own jbuild file? Or?

(Maybe what I’m asking is confused because I am.)