Re: Arrays oddities

  • From: demetri <demetri.spanos@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 31 Mar 2014 03:29:31 -0700

>
>
> 2) Good news! If you can rework your problem to more closely align with
> the
> use-cases the optimizer is tuned for you can pick up *much* more
> performance.
>

In the spirit of offering something more concrete, try replacing your inner
loop
with this:

    local buff = ffi.new("char[64]");
    local f = ffi.C.fopen("data.txt","r")
    for i=0,7281624-1 do
      ints[i] = ffi.C.atoi(ffi.C.fgets(buff,64,f))
    end
    ffi.C.fclose(f)

NOTE: There is no error checking here. If you use this in production
without adding
error checking then you will be making puppies and kittens sad. Please
think of the
innocent animals.

Anyway, this gets me a ~8x global speedup relative to the io/lines iterator
and the
array version is ~10% faster than the table version.

Demetri

Other related posts: