I was just getting back into working on pbLua (Lua for the
LEGO MINDSTORMS NXT) and noticed that 5.2 Work 2 is available.
OK, it was a couple of months ago, but I've now got some time
to work on it.
Actually, I am having a problem with 5.1.4 and I think it has
to do with slow but steady memory creeps during high volume
coroutine switches. As you can imagine, I'm quite happy to see
the emergency garbage collection feature finally in the flesh!
As a first rough hack, I took the user-configured part of my luaconf.h
from 5.1.4 and pasted it into the same area in the new project.
The first major problem I hit is that the #define for luai_hashnum
requires floating point math, which I have, but may turn off.
Can I ask for (or supply if needed) a patch to make this work on
integer only builds of Lua?
Luiz Henrique de Figueiredo wrote:
>> The first major problem I hit is that the #define for luai_hashnum
>> requires floating point math, which I have, but may turn off.
> If lua_Number is int then just use
> #define luai_hashnum(i,d) i=d
> If lua_Number is long and long is not the same size as int then you'll
> probably want to mixed its bytes into something that fits an int.
I understand that, what I was getting at was that maybe this is a
an issue that can be fixed (if it's actually a problem) luaconf.h
>> Can we submit proposed patches here?
> Sure, it'll help others. Thanks.
Lua 5.2 Work 2 is now compiling clean on bare metal for the LEGO
I had one user that had an issue with 5.1.4 that thought it would
be a good idea to do something like this:
co = coroutine.create( function( n ) )
while n>0 do
n = n-1
The main loop basically called the function with some arbitrary
value for n and then control was passed back and forth to the coroutine
until n was 0.
Simplest thing that could possibly work - but it broke. And I ended
up doing a ton of research on setjmp() and friends and finally concluded
that the heap was exhausted and I needed emergency garbage collection.
SO then I jumped ahead and got the Work 2 code, spent a grand total
of about 2 hours getting things plugged into my environment and
fixing compiler/linker errors, and now I have this case working
with no problems at all!!!
Great job, everyone! Especially for the emergency garbage collection.
Code size is a bit bigger than the old Lua, but not too horribly
I'll post more notes as I learn more about this build. So far, so good.
On Friday 19, Ralph Hempel wrote:
> Simplest thing that could possibly work - but it broke. And I ended
> up doing a ton of research on setjmp() and friends and finally concluded
> that the heap was exhausted and I needed emergency garbage collection.
> On Friday 19, Ralph Hempel wrote:
>> Simplest thing that could possibly work - but it broke. And I ended
>> up doing a ton of research on setjmp() and friends and finally concluded
>> that the heap was exhausted and I needed emergency garbage collection.
> There is a Emergency GC patch for Lua 5.1.4:
> http://lua-users.org/wiki/EmergencyGarbageCollector >
> It is even being used by eLua 0.7 release.
I'm aware of that project, and the patch for 5.1.4 - I just got so
excited that there was a 5.2 to try with everything built in that
I could not resist.
The Emergency patch has been around for a year or so, right. I really
should have picked it up sooner to try out, but that extra load user
case did not come up until a few weeks ago, so I had no real need
to use it then.
On Saturday 20, James Snyder wrote:
> This is a question I've actually had, that I'm wondering if perhaps
> Robert or someone else can comment on, what are the effective
> differences between these two EGC implementations?
I haven't had time to look into how Lua 5.2 implements it's EGC. I plan on
taking the time, once the new environment changes settle down.
> It looks as if Robert's patch has a few more configurable options (gc
> on memory limit vs gc on alloc failure), but I haven't dug into any of
> the implementation differences yet.
I think the extra features the patch has, should be possible with a custom
allocator function in Lua 5.2. If it is not possible to implement those
features with a simple allocator, then I will be creating a patch for Lua 5.2
at some point.
> FWIW, the EGC patch has been working quite well in eLua :-)
Good to hear. I will continue to maintain the patch for Lua 5.1.x, for anyone
that needs the EGC feature but can't upgrade to Lua 5.2 (which is still in
flux and not an official release yet).