Browse thread
Native code compile time question
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jon Harrop <jonathandeanharrop@g...> |
| Subject: | Re: [Caml-list] Native code compile time question |
On Friday 05 September 2008 17:26:10 Raj Bandyopadhyay wrote: > Hi all > > I am implementing a language by generating OCaml code for input source > and using the OCaml native code compiler. However, I've run into a > strange problem. > > On using my code generator on a large program, I generate a file > containing about 75K lines of OCaml. The native code compiler takes more > than 30 *minutes* to compile this file! The bytecode compiler takes > about 5 secs. > > I ran the native code compiler without any -inline or other > optimizations and its still the same. > > For smaller OCaml files, the compilation time is ok for me. For example, > it takes about 12 seconds to compile a 15K line OCaml file. I have had similar problems and, as you have almost certainly already guessed, the problem is that the OCaml compiler is designed to optimize hand-written code and its optimizer can easily run away when presented with machine generated code. In my case, optimization was irrelevant so I ended up encoding the data in strings and parsing them at run-time. > Any ideas why this might be happening and how I can deal with this? You might consider rebuilding ocamlopt with profiling to see where the time is being spent in the OCaml compiler itself and then make sure your compiler does not generate pathological cases. Without seeing some of your code it is impossible for me to give a more productive answer but I found that some inlining-related optimizations can bog ocamlopt down without affecting ocamlc. So you might also try -inline 0. Can you post the generated code? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e