lua-users home
lua-l archive

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


> > > I noticed you decreased the maximum array size for sort from 2^50 to
> > > 2^40 elements.
> > > This actually brings it into range of real life operations. (it's not
> > > unheard of to have 46bits of addressable memory now).
> > > Though a single threaded sort operation might take a long time with
> > > that much data,
> > > Imagine the disappointment when your multi-month sort overruns your stack ;)
> > 
> > Real size is still limited by the size of an 'int', which in most
> > machines is 2^31.
> 
> Another thing: the comment in the code is wrong. The recursion ends
> with size 3 (not 1), so the real limit for a 40-slot stack is (2^42 - 1)
> elements. Given that each element in a Lua has 2^4 bytes, we have
> ~2^46 bytes for the array, leaving little room for software in memory
> (assuming 'bits' == byte :-).

Yet another thing: the comment in the code (and our discussion so far)
is completely wrong :-) The recursion is in the C stack, not in the Lua
stack! We do not even need to check the Lua stack, as the whole algorithm
uses a fixed (and small) number of slots. (I am not sure it is worth
releasing a rc3 only to fix that, which is not a bug, but it will be
fixed in the next release.)

-- Roberto