[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Tons of reallocs in Lua - why?
- From: "Ivan-Assen Ivanov" <ivanassen@...>
- Date: Sun, 10 Dec 2006 18:21:31 +0200
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?