r3772 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Mon Feb 16 15:22:00 CET 2009
Author: phk
Date: 2009-02-16 15:22:00 +0100 (Mon, 16 Feb 2009)
New Revision: 3772
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_expire.c
Log:
Compress objcore a bit more by squezing 32 bit fields to 8 bit, still
leaving plenty of space.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2009-02-16 13:40:29 UTC (rev 3771)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2009-02-16 14:22:00 UTC (rev 3772)
@@ -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 at phk.freebsd.dk>
@@ -262,11 +262,14 @@
#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 --------------------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2009-02-16 13:40:29 UTC (rev 3771)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2009-02-16 14:22:00 UTC (rev 3772)
@@ -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 at phk.freebsd.dk>
@@ -63,14 +63,16 @@
#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 @@
{
struct objcore *oc;
double when;
- const char *what;
+ unsigned char what;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore;
@@ -96,14 +98,14 @@
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 @@
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 @@
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 @@
}
}
- 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 @@
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 @@
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 @@
* 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 @@
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);
}
More information about the varnish-commit
mailing list