On Sun, 25 Nov 2007 21:32:13 -0500 "Sam Carleton" <[EMAIL PROTECTED]> wrote:
> With this memory leak in my simple Apache module, I am considering > rewriting the whole module. Right now there are two files small files > that the module reads every time. One is a small (less then a 1K) > configuration file and the other is a small (1K ~20K) xml file. In > the rewrite, I am considering caching the data in these files and > reading them only if they are changed. The question though is: > Considering how small these files are, will the performance gains be > worth the extra development time? Another option would be to switch > from using libxml2 to expat for the XML parsing. > > Oh, what type of load is the server under? The server is driving a > kiosk system where there are normally a hand full of kiosk but there > could be as many as 100 under very heavy use. If it's a kiosk system then it's not really going to matter how you're processing that as the main bottle neck is a human, so you can probably ignore the fact that it's in memory cache. If you want to store the file in memory though, put a void * in your module's .c file, outside of the module routines, so that it's defined at initialisation. Then in your init routines allocate the memory for it. The trouble that you might find yourself in is how to lock this pointer when the file changes AND the memory is being read/written by concurrent processes. For this reason I suggest that you stick to reading the data on access from disk. If disk IO is a problem then put the file on the RAM disk, where there is going to be little difference between having the data read at module run time or from memory - some file system operations are atomic, so you don't need to worry so much. HTH. -- The 28.8 frame relay to south lata is unreliable because of Bernard Shifman threatening to sue. RedHat is selling their dialup customers to Earthlink. :: http://www.s5h.net/ :: http://www.s5h.net/gpg.html
signature.asc
Description: PGP signature