Demetri, Thanks a lot. I am absolutely amazed, x6.7 improvement. Almost on par with C speed for the whole logic. That is _fast_. And so easy. I didn't get ffi really well and will need some time to grasp it. Just started yesterday and wanted to know more about it. Mike, :) it is not the ffi version that is in production of course, but the logic (and we cannot change it, since a whole stack relies on it) :D I am so much into lua, since say weeks, that I think 1-based array and not 0-based anymore. My mistake. But I treat myself. Anyway, many thanks both of you, you helped to get my feet wet. Bye Date: Mon, 31 Mar 2014 03:29:31 -0700 Subject: Re: Arrays oddities From: demetri.spanos@xxxxxxxxx To: luajit@xxxxxxxxxxxxx 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 loopwith 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 thearray version is ~10% faster than the table version. Demetri