lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 29/01/2008, Mike Pall <> wrote:
> Try setting the STACKSIZE statement in the .DEF file for the EXE
> as MSDN recommends.

I think that did it, thanks. Actually I used the /STACK linker option
which does the same thing. It's still a bit limited in max number of
threads (well, compared to the non-JITed tests anyway, which are
admittedly crazy), and it takes an obscene amount of memory (again,
compared to non-JITed coroutine tests). But it does run faster. Around
50% faster with threads that do nothing other than yield in a loop,
and anywhere from 2 to 4 times as fast with threads that actually do a
little work.

It's not exactly stable though. It seems ok with my console test prog,
but it crashes within a minute when using a GUI test prog based on
wxLua (doesn't do much yet, really, it's basically an empty window,
running the scheduler in the idle event and outputting to the console,
heheh... but the tests are mostly the same in both cases).

Could that be because the stack size is now too low? I've set it to
128k for the moment. I couldn't say, since I have no clue how LuaJIT
and Coco handle coroutines, nor exactly what has an impact on how much
stack space it needs. Of course, I imagine that anything happening in
a C library like wxLua, requires stack space as usual.

> > Anyway, about coroutines in LuaJIT... My whole point of using
> > coroutines was because I don't know of any other threading mechanism
> > that could handle such large amounts of threads so efficiently. Should
> > I forget about LuaJIT for this particular demo app? I don't know a
> > great deal about actual fibers in windows.
> Maybe yes, maybe not. It depends on what you're doing. LuaJIT 1.x
> relies on Windows fibers to provide individual stacks for
> coroutines. So there is some memory overhead and some overhead
> for coroutine creation and coroutine switching due to the calls
> to the WIN32 fiber functions (it's much faster on Linux with
> inlined coroutine switching).

I don't know, but I'm guessing that the Linux implementation, with
regards to coroutines, is not something that could only work on Linux?
Either way, on Windows, I'm not sure what the advantage is supposed to
be of using win32 fibers for it.

In any case, thanks for your help!