lua-users home
lua-l archive

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


the recent thread about multithreaded allocation reminded me to
ask a question I'm wondering about for quite some time.
All of the Lua activity in our application happens in a single thread,
so I recently tried to supply to Lua a very fast, lightweight single-threaded
allocator - the so-called TLSF. Imagine my surprise when everything actually
started running slower. The investigation showed that Lua performs an
insane (by the standards of the programming style I'm used to)
number of reallocs, and TLSF doesn't provide a reasonable
realloc at all, substituting it with a malloc+memcpy+free combination.

Is there a good reason for this style of constantly reallocating very small
chunks of memory? Maybe something to do with low memory footprint etc?
We have practically zero (ok, maybe single digits) of reallocs in our
200k+ lines of code codebase.
Is it something we might see changed in future versions of Lua?

Best regards,