[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: VEGAS algorithm for monte carlo integration in LuaJIT2
- From: Duncan Cross <duncan.cross@...>
- Date: Sun, 22 Jan 2012 12:26:53 +0000
On Sun, Jan 22, 2012 at 9:03 AM, Francesco Abbate
<francesco.bbt@gmail.com> wrote:
> 2012/1/22 steve donovan <steve.j.donovan@gmail.com>:
>> So this is the performance bottleneck; LuaJIT's math.random is an
>> optimized fast call. So the Lua/C boundary is penalizing your other
>> random generator.
>
> Well, this should'n be the case because we call the RNG functions
> directly using the FFI interface and therefore there shouldn't be any
> performance panalty.
>
I may be wrong, but I believe that while FFI *minimizes* the cost of
calling into C from LuaJIT, it does not - and cannot - fully eliminate
it. There is still an overhead to calling into an arbitrary C function
from Lua, even if there's no callbacks involved, and your best bet for
performance is still to stay on one side of the Lua/C boundary as much
as possible.
-Duncan