memory mapped store entries

From: Stephen R. van den Berg <srb@dont-contact.us>
Date: Mon, 24 Aug 1998 15:21:11 +0200

Before I go through the trouble to separate out a (rather sizeable)
memory-mapped store entry patch, I'd like to ask for your opinion
about its viability in its current form.

To get a feel for the situation:

I reduced the size of the StoreEntry struct to 28 bytes (see patch
at the bottom of this E-mail).
I put in a new pointer in StoreEntry towards storeSwapLogData.
This struct is tightly packed and stored in a memory mapped logfile.

Advantages:
1. Less allocation overhead, since they're all tightly packed.
2. Instant crash recovery. I.e. since the binary logfile is
   memory mapped, all the information in it is always current.
3. No race conditions upon loading the logfile because all entries
   are always current.
4. Smaller overall memory footprint because we reuse the kernel-buffer-cache.

So...
Any chance of these patches making it in? Duane?
Do I need to change the format a bit?

I've been running squids with these enhancements since November 1997,
so I'd say, yes, they're solid as a rock.
I tried to make them dependent on MMAP_STORE; however, I've never
actually tested undefining MMAP_STORE, so I may have missed a spot
here or there to make it work both ways.

diff -u -b -r squid-1.2.beta24/src/structs.h squid-BuGless/src/structs.h
--- squid-1.2.beta24/src/structs.h Fri Aug 21 06:03:49 1998
+++ squid-BuGless/src/structs.h Sat Aug 22 03:32:32 1998
@@ -1153,11 +1155,38 @@
     size_t swap_hdr_sz;
 };
 
+#ifdef MMAPSTORE
+#define Skey s->key
+#define Stimestamp s->timestamp
+#define Slastref s->lastref
+#define Sexpires s->expires
+#define Slastmod s->lastmod
+#define Sswap_file_sz s->swap_file_sz
+#define Srefcount s->refcount
+#define Sflag s->flags
+#define Sswap_file_number s->swap_file_number
+#else
+#define Skey key
+#define Stimestamp timestamp
+#define Slastref lastref
+#define Sexpires expires
+#define Slastmod lastmod
+#define Sswap_file_sz swap_file_sz
+#define Srefcount refcount
+#define Sflag flags
+#define Sswap_file_number swap_file_number
+#endif
+
 struct _StoreEntry {
     /* first two items must be same as hash_link */
+#ifdef MMAPSTORE
+ storeSwapLogData *s;
+#else
     const cache_key *key;
+#endif
     StoreEntry *next;
     MemObject *mem_obj;
+#ifndef MMAPSTORE
     time_t timestamp;
     time_t lastref;
     time_t expires;
@@ -1166,6 +1195,7 @@
     u_short refcount;
     u_short flag;
     int swap_file_number;
+#endif
     dlink_node lru;
     u_short lock_count; /* Assume < 65536! */
     mem_status_t mem_status:3;
@@ -1184,6 +1214,9 @@
     int suggest;
     fileMap *map;
     int swaplog_fd;
+#ifdef MMAPSTORE
+ storeSwapLogData*mmapbase,*mmapend,*mmapmax,*mmapfreelist;
+#endif
 };
 
 struct _request_flags {
@@ -1404,16 +1437,18 @@
 };
 
 struct _storeSwapLogData {
- char op;
- int swap_file_number;
+ unsigned char key[MD5_DIGEST_CHARS];
+ size_t swap_file_sz;
     time_t timestamp;
     time_t lastref;
     time_t expires;
     time_t lastmod;
- size_t swap_file_sz;
     u_short refcount;
     u_short flags;
- unsigned char key[MD5_DIGEST_CHARS];
+#ifndef MMAPSTORE
+ char op;
+#endif
+ int swap_file_number;
 };
 
 /* object to track per-action memory usage (e.g. #idle objects) */
 

-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg (AKA BuGless).
This signature third word omitted, yet is comprehensible.
Received on Tue Jul 29 2003 - 13:15:52 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:52 MST