At 9:15 PM +1000 10/25/02, Rhys Weatherley wrote:
I was just having a look at the packfile format code, and I
have a suggestion on load-time performance of the code segment.

Currently, you read the file, parse out the various sections,
copy them elsewhere in memory, and byte-swap as necessary.
The overhead of doing this could be quite significant on large
applications/modules.

A "trick" that I've found very useful in the past is to design
the bytecode format so that it can be mmap'ed into a block of
memory, and then executed almost immediately with the minimum
number of fixups.  Rather than copying the instructions, you
execute them directly out of the mmap'ed region.
Gah. This was how things were originally done, and what was supposed to be followed through on--if the segment on disk matched the host size/endianness, it's supposed to be just mmapped in. The constants section may need fixup (string and PMC constants, certainly) but the code itself is supposed to be shared. This is good for both speed reasons (as you noted) and for process size reasons, since we're definitely facing the potential for a half-zillion Apache mod_parrot processes mapping in the same bytecode to execute server-side programs.

If this has been broken, then we need to fix it, as it's a bug.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk

Reply via email to