Re: [OPTIMIZATION] RAM (previously: Random Thought)

From: Fizal (amustapa@gamebox.net)
Date: 10/13/00


At 09:55 AM -0700 13/10/2000, George Greer wrote:
>If you're keeping a full index, you don't need the length of the string
>anymore.  You can remove it and keep the trailing NUL for the end of
>string.  You'll only save 3 bytes per string but that adds up.  You may
>want the length of the string to pre-malloc() for though.

Hmm... didn't see that at all at the time. Will try and see how it goes...

>With a complete index, you don't really have to separate them into
>different files.  The format doesn't care what is in it, after all.

Was thinking of dividing them up so that I know what goes where. But like
you said, it doesn't really care. I'll recombine them... err, one of these
days....

>Getting a string from the file with a pre-computed index shouldn't be a lot
>slower than using a pointer indirection to get there, assuming it's in the
>OS cache.  Your overhead would come down to about 2 system calls
>(seek+read) which, depending on your operating system, may be well worth
>the extra RAM saved.
>
>One idea which would really be neat on a Unix system is to mmap() the data
>file.  Then you just use a pointer into the mmap() section and your program
>acts as if nothing is different from stock (except OLC, which would need to
>still only append).  The difference to the operating system is that it can
>throw away your world strings for memory because the file has a backing
>store it can reload as necessary.  Your overhead in this case is reduced to
>only whatever memory management tricks your operating system has to pull to
>map the file.  The downside is you might be charged memory (though perhaps
>a different sort of memory that isn't limited by the administrator) because
>even though the memory is expendable and not really "there", it's still
>possibly used.

Actually, both you and Erwin did mention about mmap(). The only prob is, I
sort of understood what it does but I don't really understand how to make
use of it. *shrug* Like I said, I can still be consider a beginner. Maybe
it's time for me to do a research on it (which I should have done earlier).

Thanx for the info :)





---

Afizal Mustapa
Petaling Jaya, Selangor, Malaysia.
(amustapa@hotmail.com)


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT