]> err.no Git - varnish/commitdiff
Compress objcore a bit more by squezing 32 bit fields to 8 bit, still
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 16 Feb 2009 14:22:00 +0000 (14:22 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 16 Feb 2009 14:22:00 +0000 (14:22 +0000)
leaving plenty of space.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3772 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_expire.c

index 0101ee34e4d4db4cb8cdd780a7f885ac13605cef..76ea74f5aa3aa3921984b645f34395dc9fe6ba08 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2008 Linpro AS
+ * Copyright (c) 2006-2009 Linpro AS
  * All rights reserved.
  *
  * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
@@ -262,11 +262,14 @@ struct objcore {
 #define OBJCORE_MAGIC          0x4d301302
        struct object           *obj;
        double                  timer_when;
-       const char              *timer_what;
+       unsigned char           timer_what;
+#define OC_T_TTL               1
+#define OC_T_PREFETCH          2
+       unsigned char           flags;
+#define OC_F_ONLRU             (1<<0)
        unsigned                timer_idx;
        VTAILQ_ENTRY(objcore)   list;
        VTAILQ_ENTRY(objcore)   lru_list;
-       int                     on_lru;
 };
 
 /* Object structure --------------------------------------------------*/
index 8d14e89ac2e9b797b61d62b08e6fa61469015a89..e69393fff4ece9274e7f48184430d9b4707cdac5 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2008 Linpro AS
+ * Copyright (c) 2006-2009 Linpro AS
  * All rights reserved.
  *
  * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
 #include "vcl.h"
 #include "hash_slinger.h"
 
-static const char * const tmr_prefetch = "prefetch";
-static const char * const tmr_ttl      = "ttl";
-
 static pthread_t exp_thread;
 static struct binheap *exp_heap;
 static struct lock exp_mtx;
 static VTAILQ_HEAD(,objcore) lru = VTAILQ_HEAD_INITIALIZER(lru);
 
+static const char *timer_what[] = {
+       [OC_T_TTL]      =       "TTL",
+       [OC_T_PREFETCH] =       "Prefetch",
+};
+
 /*
  * This is a magic marker for the objects currently on the SIOP [look it up]
  * so that other users of the object will not stumble trying to change the
@@ -87,7 +89,7 @@ update_object_when(const struct object *o)
 {
        struct objcore *oc;
        double when;
-       const char *what;
+       unsigned char what;
 
        CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
        oc = o->objcore;
@@ -96,14 +98,14 @@ update_object_when(const struct object *o)
 
        if (o->prefetch < 0.0) {
                when = o->ttl + o->prefetch;
-               what = tmr_prefetch;
+               what = OC_T_PREFETCH;
        } else if (o->prefetch > 0.0) {
                assert(o->prefetch <= o->ttl);
                when = o->prefetch;
-               what = tmr_prefetch;
+               what = OC_T_PREFETCH;
        } else {
                when = o->ttl + HSH_Grace(o->grace);
-               what = tmr_ttl;
+               what = OC_T_TTL;
        }
        assert(!isnan(when));
        oc->timer_what = what;
@@ -140,7 +142,7 @@ EXP_Insert(struct object *o)
        binheap_insert(exp_heap, oc);
        assert(oc->timer_idx != BINHEAP_NOIDX);
        VTAILQ_INSERT_TAIL(&lru, oc, lru_list);
-       oc->on_lru = 1;
+       oc->flags |= OC_F_ONLRU;
        Lck_Unlock(&exp_mtx);
 }
 
@@ -166,7 +168,7 @@ EXP_Touch(const struct object *o)
        CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
        if (Lck_Trylock(&exp_mtx))
                return (retval);
-       if (oc->on_lru) {
+       if (oc->flags & OC_F_ONLRU) {
                VTAILQ_REMOVE(&lru, oc, lru_list);
                VTAILQ_INSERT_TAIL(&lru, oc, lru_list);
                VSL_stats->n_lru_moved++;
@@ -273,12 +275,13 @@ exp_timer(void *arg)
                        }
                }
 
-               assert(oc->on_lru);
+               assert(oc->flags & OC_F_ONLRU);
                Lck_Unlock(&exp_mtx);
 
-               WSL(&ww, SLT_ExpPick, 0, "%u %s", o->xid, oc->timer_what);
+               WSL(&ww, SLT_ExpPick, 0, "%u %s", o->xid,
+                   timer_what[oc->timer_what]);
 
-               if (oc->timer_what == tmr_prefetch) {
+               if (oc->timer_what == OC_T_PREFETCH) {
                        o->prefetch = 0.0;
                        sp->obj = o;
                        VCL_prefetch_method(sp);
@@ -294,7 +297,7 @@ exp_timer(void *arg)
                        assert(oc->timer_idx != BINHEAP_NOIDX);
                        Lck_Unlock(&exp_mtx);
                } else {
-                       assert(oc->timer_what == tmr_ttl);
+                       assert(oc->timer_what == OC_T_TTL);
                        sp->obj = o;
                        VCL_timeout_method(sp);
                        sp->obj = NULL;
@@ -305,7 +308,7 @@ exp_timer(void *arg)
                        Lck_Lock(&exp_mtx);
                        assert(oc->timer_idx == BINHEAP_NOIDX);
                        VTAILQ_REMOVE(&lru, o->objcore, lru_list);
-                       oc->on_lru = 0;
+                       oc->flags &= ~OC_F_ONLRU;
                        VSL_stats->n_expired++;
                        Lck_Unlock(&exp_mtx);
                        HSH_Deref(&o);
@@ -353,7 +356,7 @@ EXP_NukeOne(struct sess *sp)
                 * actions below.
                 */
                VTAILQ_REMOVE(&lru, oc, lru_list);
-               oc->on_lru = 0;
+               oc->flags &= ~OC_F_ONLRU;
                binheap_delete(exp_heap, oc->timer_idx);
                assert(oc->timer_idx == BINHEAP_NOIDX);
                VSL_stats->n_lru_nuked++;
@@ -389,7 +392,7 @@ EXP_NukeOne(struct sess *sp)
        binheap_insert(exp_heap, oc);
        assert(oc->timer_idx != BINHEAP_NOIDX);
        VTAILQ_INSERT_TAIL(&lru, oc, lru_list);
-       oc->on_lru = 1;
+       oc->flags |= OC_F_ONLRU;
        Lck_Unlock(&exp_mtx);
        return (0);
 }