[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua memory usage
- From: Daniel Silverstone <dsilvers@...>
- Date: Tue, 09 Sep 2003 14:45:05 +0100
On Tue, 2003-09-09 at 14:47, David Jones wrote:
> I don't think it's worth changing Lua, all the most popular
> architectures align to 4 bytes with no or almost no penalty and that
> will be the case for a long time. Architectures that routinely align to
> 8 bytes can usually to be convinced to use 4 byte alignment with little
> or no penalty.
Erm, it can always be worthwhile moving around the order of items in
structs and classes.
At one job, I garnered a three-fold speedup in one particular code area
merely by moving one pointer from the bottom of a struct declaration to
the top of it, thereby seriously improving locality of reference across
the algorithms using the data structures.
Ordering the contents of a struct first by alignment requirements and
then by type can often garner speedups (and memory requirement
reductions) Also making sure that the bits of the lua structures looked
at by the garbage collector are all together will improve the speed of
that, especially if you can ensure it'll load them all into one cache
line (on a modern cpu).
Don't disregard the gains to be made from reordering structures just
because unaligned accesses aren't penalised as much as they once were
;-)
D.
--
Daniel Silverstone http://www.digital-scurf.org/
Hostmaster, Webmaster, and Chief Code Wibbler: Digital-Scurf Unlimited
GPG Public key available from keyring.debian.org KeyId: 20687895