RE: Arrays oddities

  • From: Alain Meunier <deco33@xxxxxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Mon, 31 Mar 2014 11:34:58 +0200

Ok..

So basically anything my bytes[5] may be lost if the system need that memory 
space, right ?
Obviously it will not be the case with bytes[2] because it is in the bounds.

Actually, i don't really care the access time, I just want the fastest as a 
whole. And even if faster access, the whole code is slower. That is odd to me.
If faster in one cycle, 1000 cycles should be faster too.

I don't get it Mike, I am sorry.
And  this code is realistic enough to be used in production. I just try to 
fasten it.

> Date: Mon, 31 Mar 2014 11:24:39 +0200
> From: mike-1403@xxxxxxxxxx
> To: luajit@xxxxxxxxxxxxx
> Subject: Re: Arrays oddities
> 
> Alain Meunier wrote:
> > 1) Why can we allocate a value in an array out of the bound ?
> 
> Allocate? You mean access. The FFI is a low-level interface. It
> doesn't do bounds-checking (which isn't possible on C types in
> general, anyway). http://luajit.org/ext_ffi_semantics.html#policy
> 
> > 2) Should not an array be faster than a table ?
> 
> It is. If properly used in a realistic benchmark that actually
> tests array accesses (which is a single-cycle op) and not the
> random variations in something else (~ thousands of cycles).
> 
> --Mike
> 
                                          

Other related posts: