Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Bigarray is a pig
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-23 (20:57)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] Bigarray is a pig
On Fri, 23 Jul 2004, Brandon J. Van Every wrote:

> I have been looking at the sources of the Bigarray implementation.  I am
> chagrined to discover that not only does Bigarray cost a function call
> per array element access, but a number of additional piggish things
> happen per access.  

If memory serves, Ocaml can optimize the access if the size and type are 
known, getting rid of the function call overhead and type specialization.  
I don't think it gets rid of the bounds checking, tho- which is good.

Can someone who actually knows what is going on clarify this?

> To C/C++ programmers interested in performance, this
> defeats the purpose of using unboxed array elements.  If I wanted to pay
> function call overhead per element, for instance when communicating with
> OpenGL, I'd simply call functions.

Function calls aren't that expensive.  From comments in other forums:

may I respectfully suggest that you are prematurely optimizing?  A 
function call to a known function takes 1-2 clock cycles.  A cache miss, 
on the other hand, can take hundreds of clock cycles:

"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: