
Writing Performance Sensitive OCaml Code - amirmc
http://janestreet.github.io/ocaml-perf-notes.html
======
chollida1
Wow, the first 5 comments on this were about should they use LLVM:)

The author is currently writing a book about OCaml that is now available in
alpha format from here:

<http://www.realworldocaml.org/>

I've finished the first part and looked at the compiler section, and I love
this book, no affiliation in any way.

~~~
irahul
> The author is currently writing a book about OCaml that is now available in
> alpha format from here: <http://www.realworldocaml.org/>

For anyone else trying to take a peek, authorizing github doesn't necessarily
grant you access as there is some sort of whitelisting of allowed github
handles. They should make it obvious in the copywriting that not all github
accounts can take a peek.

"To login and view the book, you will need a free Github account to
authenticate with."

This sounds like you just authenticate with github and be on your merry way.

~~~
amirmc
Ah, yes. There is a whitelist. Even though the book website is 'public' it
hasn't really been advertised (apart from the initial "Hey, we're writing a
book!" announcement [1]). There were already lots of reviewers for the alpha
stages so not much need to attract more.

The beta stage might be different as the early 'bugs' will have been squashed
so that phase of writing might take a different approach.

[1] <https://news.ycombinator.com/item?id=3641355>

------
edwintorok
This is a good collection of performance tips, although I'd use
Unix.gettimeofday instead of RDTSC (RDTSC needs additional care on multicore).

Also it is interesting that OCaml's tutorial has a section on performance
(that is not something common in other language tutorials):
<http://ocaml.org/tutorials/performance_and_profiling.html>

------
toolslive
This is a good overview of performance 'idiosyncrasies'. For profiling, I tend
to use valgrind's callgrind which is easier than instrumenting the code by
hand.

------
octo_t
I'm surprised the compiler goes straight to assembly, rather than targeting
LLVM (most native programming languages) or C- (what GHC does/did)

~~~
masklinn
> I'm surprised the compiler goes straight to assembly, rather than targeting
> LLVM (most native programming languages)

Most native programming languages historically don't, and OCaml predates LLVM
by a good 7 years.

> or C- (what GHC does/did)

Cmm is an intermediate language specific to GHC before the backend[1], GHC's
default backend is a native generator.

[1] or more precisely "an other" intermediate language, since there's also
Core.

