Re: Where do I send the Paypal to support the Group

  • From: Elias Hogstvedt <eliashogstvedt@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 13 Dec 2014 11:25:26 +0100

You can probably try to use ipairs instead of pairs in some places. If the
table is an array (keys that are numbers from 1 to X) and doesn't have
holes in it, ipairs will work and should faster. In the sma function since
you're not using the variable tval a simple "for ndx, #arr do" will be
better rather (reading-wise) than replacing pairs with ipairs.

As for QueryPerformanceCounter mentioned by demetri you can copy paste some
code from here
https://github.com/CapsAdmin/goluwa/blob/master/.base/lua/libraries/system.lua#L96-L133
(where "get" is the function) if you want.

Also, it's Lua not LUA, Lua is not an acronym, Lua means moon in
Portuguese. :)

On Sat, Dec 13, 2014 at 5:51 AM, Joe Ellsworth <joexdobs@xxxxxxxxx> wrote:
>
>  Thanks demetri.  Your suggestions are appreciated.    You are right I am
> not a lua jit expert but I do appreciate the feedback and advice.    The
> response times  are in seconds.   I averaged results across runs so I don't
> think a few 100ms will make a material difference.
>
> I have been dabbling with FFI to use externally allocated arrays intending
> to bypass some of the limits imposed by the Lua GC.    The results are
> promising but not yet conclusive.   A draft version is at:
> http://bayesanalytic.com/access-extra-memory-from-lua-jit/    I will l
> update as I improve the Lua code.   The big issue right is that I still
> have not successfully allocated memory beyond 4 Gig even using the
> ffi.C.malloc().        Please do send me your suggestions for improvements
> and I will add them to the article. Let me know if you want attribution.
>
>
> On 12/12/2014 4:30 PM, demetri wrote:
>
>   I am already spreading the word  [link to Julia vs LuaJIT post]
>
>
>  This is an interesting comparison to Julia but you might want to
> consider two things:
>
>  1) if these tests run short enough that milliseconds matter (I can't
> tell just from looking at them), then you should get a more precise
> timer than os.clock. You may want to ffi.cdef QueryPerformanceCounter
> since you seem to be on Windows.
>
>  2) Since you're already doing a variant of the Julia code with typed
> arrays you might do the same in your LuaJIT example. In particular,
> in your sma function you could replace
>
>  local tout = {}
>
>  with
>
>  local tout = {slots = ffi.new("float[?]",numElements)}
>
>  or something analogous. That would be the most fair comparison
> if I'm understanding your example correctly (if you are new to ffi
> code, the wrapper table around ffi.new is one of several ways to
> ensure that the allocated memory is anchored for the GC and
> lasts beyond the function invocation).
>
>  Anyway, I am definitely interested in LuaJIT vs Julia comparisons
> as a matter of professional education, so thanks for taking the
> time to try this out :) I think this kind of work aimed at educating
> newcomers is probably more valuable than monetary donations.
> I think most people on this list are more pressed for free time
> than they are for a few incremental donations.
>
>  Cheers,
> Demetri
>
>
>

Other related posts: