r5046 - in branches/2.1: . varnish-cache/bin/varnishd varnish-cache/bin/varnishtest/tests varnish-cache/include varnish-cache/lib/libvarnish varnish-cache/lib/libvcl
tfheen at varnish-cache.org
tfheen at varnish-cache.org
Tue Jul 13 12:26:48 CEST 2010
Author: tfheen
Date: 2010-07-13 12:26:47 +0200 (Tue, 13 Jul 2010)
New Revision: 5046
Modified:
branches/2.1/
branches/2.1/varnish-cache/bin/varnishd/cache.h
branches/2.1/varnish-cache/bin/varnishd/cache_backend.h
branches/2.1/varnish-cache/bin/varnishd/cache_backend_cfg.c
branches/2.1/varnish-cache/bin/varnishd/cache_hash.c
branches/2.1/varnish-cache/bin/varnishd/flint.lnt
branches/2.1/varnish-cache/bin/varnishd/hash_critbit.c
branches/2.1/varnish-cache/bin/varnishd/vparam.h
branches/2.1/varnish-cache/bin/varnishtest/tests/c00019.vtc
branches/2.1/varnish-cache/bin/varnishtest/tests/r00325.vtc
branches/2.1/varnish-cache/bin/varnishtest/tests/r00416.vtc
branches/2.1/varnish-cache/bin/varnishtest/tests/v00011.vtc
branches/2.1/varnish-cache/include/vct.h
branches/2.1/varnish-cache/include/vev.h
branches/2.1/varnish-cache/lib/libvarnish/tcp.c
branches/2.1/varnish-cache/lib/libvarnish/vev.c
branches/2.1/varnish-cache/lib/libvcl/vcc_dir_random.c
Log:
Merge r4859-r4861: Make the critbit "Y" a independently allocated struct
r4859:
Make the critbit "Y" a independently allocated struct, rather than
using the objhead as carrier for it.
The time difference between objhead freeing and Y freeing is very
significant on systems with rolling URLS (ie: "article=%d") resulting
in far too many objheads being stuck on the cooling list.
r4860:
Also cool off objheaders
r4861:
Add a single write memory barrier, to be absolutely 100% sure that
the tree is sane at all points.
Property changes on: branches/2.1
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk:4637,4640,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk:4637,4640,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Modified: branches/2.1/varnish-cache/bin/varnishd/cache.h
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache.h 2010-07-13 09:55:33 UTC (rev 5045)
+++ branches/2.1/varnish-cache/bin/varnishd/cache.h 2010-07-13 10:26:47 UTC (rev 5046)
@@ -206,6 +206,7 @@
#define WORKER_MAGIC 0x6391adcf
struct objhead *nobjhead;
struct objcore *nobjcore;
+ void *nhashpriv;
struct dstat stats;
double lastused;
Property changes on: branches/2.1/varnish-cache/bin/varnishd/cache_backend.h
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishd/cache_backend.h:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/bin/varnishd/cache_backend.h:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/bin/varnishd/cache_backend_cfg.c
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Modified: branches/2.1/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/cache_hash.c 2010-07-13 09:55:33 UTC (rev 5045)
+++ branches/2.1/varnish-cache/bin/varnishd/cache_hash.c 2010-07-13 10:26:47 UTC (rev 5046)
@@ -146,6 +146,10 @@
w->nobjhead = NULL;
w->stats.n_objecthead--;
}
+ if (w->nhashpriv != NULL) {
+ free(w->nhashpriv);
+ w->nhashpriv = NULL;
+ }
}
void
Modified: branches/2.1/varnish-cache/bin/varnishd/flint.lnt
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/flint.lnt 2010-07-13 09:55:33 UTC (rev 5045)
+++ branches/2.1/varnish-cache/bin/varnishd/flint.lnt 2010-07-13 10:26:47 UTC (rev 5046)
@@ -157,6 +157,7 @@
-emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
-emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
-emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean
+-emacro(506, VSTAILQ_FOREACH_SAFE) // constant value boolean
-esym(765, vcc_ProcAction) // could be made static
-esym(759, vcc_ProcAction) // could be moved to module
Modified: branches/2.1/varnish-cache/bin/varnishd/hash_critbit.c
===================================================================
--- branches/2.1/varnish-cache/bin/varnishd/hash_critbit.c 2010-07-13 09:55:33 UTC (rev 5045)
+++ branches/2.1/varnish-cache/bin/varnishd/hash_critbit.c 2010-07-13 10:26:47 UTC (rev 5046)
@@ -43,11 +43,10 @@
#include "cache.h"
#include "hash_slinger.h"
#include "cli_priv.h"
+#include "vmb.h"
static struct lock hcb_mtx;
-static VTAILQ_HEAD(,objhead) laylow = VTAILQ_HEAD_INITIALIZER(laylow);
-
/**********************************************************************
* Table for finding out how many bits two bytes have in common,
* counting from the MSB towards the LSB.
@@ -93,10 +92,13 @@
*/
struct hcb_y {
+ unsigned magic;
+#define HCB_Y_MAGIC 0x125c4bd2
unsigned short critbit;
unsigned char ptr;
unsigned char bitmask;
volatile uintptr_t leaf[2];
+ VSTAILQ_ENTRY(hcb_y) list;
};
#define HCB_BIT_NODE (1<<0)
@@ -108,6 +110,11 @@
static struct hcb_root hcb_root;
+static VSTAILQ_HEAD(, hcb_y) cool_y = VSTAILQ_HEAD_INITIALIZER(cool_y);
+static VSTAILQ_HEAD(, hcb_y) dead_y = VSTAILQ_HEAD_INITIALIZER(dead_y);
+static VTAILQ_HEAD(, objhead) cool_h = VTAILQ_HEAD_INITIALIZER(cool_h);
+static VTAILQ_HEAD(, objhead) dead_h = VTAILQ_HEAD_INITIALIZER(dead_h);
+
/**********************************************************************
* Pointer accessor functions
*/
@@ -146,6 +153,7 @@
hcb_r_y(struct hcb_y *y)
{
+ CHECK_OBJ_NOTNULL(y, HCB_Y_MAGIC);
assert(!((uintptr_t)y & (HCB_BIT_NODE|HCB_BIT_Y)));
return (HCB_BIT_Y | (uintptr_t)y);
}
@@ -169,6 +177,7 @@
{
unsigned char u, r;
+ CHECK_OBJ_NOTNULL(y, HCB_Y_MAGIC);
for (u = 0; u < DIGEST_LEN && oh1->digest[u] == oh2->digest[u]; u++)
;
assert(u < DIGEST_LEN);
@@ -186,7 +195,7 @@
*/
static struct objhead *
-hcb_insert(struct hcb_root *root, struct objhead *oh, int has_lock)
+hcb_insert(struct worker *wrk, struct hcb_root *root, struct objhead *oh, int has_lock)
{
volatile uintptr_t *p;
uintptr_t pp;
@@ -205,6 +214,7 @@
while(hcb_is_y(pp)) {
y = hcb_l_y(pp);
+ CHECK_OBJ_NOTNULL(y, HCB_Y_MAGIC);
assert(y->ptr < DIGEST_LEN);
s = (oh->digest[y->ptr] & y->bitmask) != 0;
assert(s < 2);
@@ -231,9 +241,9 @@
/* Insert */
- y2 = (void*)&oh->u;
- memset(y2, 0, sizeof *y2);
- (void)hcb_crit_bit(oh, hcb_l_node(*p), y2);
+ CAST_OBJ_NOTNULL(y2, wrk->nhashpriv, HCB_Y_MAGIC);
+ wrk->nhashpriv = NULL;
+ (void)hcb_crit_bit(oh, oh2, y2);
s2 = (oh->digest[y2->ptr] & y2->bitmask) != 0;
assert(s2 < 2);
y2->leaf[s2] = hcb_r_node(oh);
@@ -244,6 +254,7 @@
while(hcb_is_y(*p)) {
y = hcb_l_y(*p);
+ CHECK_OBJ_NOTNULL(y, HCB_Y_MAGIC);
assert(y->critbit != y2->critbit);
if (y->critbit > y2->critbit)
break;
@@ -253,6 +264,7 @@
p = &y->leaf[s];
}
y2->leaf[s2] = *p;
+ VWMB();
*p = hcb_r_y(y2);
return(oh);
}
@@ -282,8 +294,7 @@
assert(s < 2);
if (y->leaf[s] == hcb_r_node(oh)) {
*p = y->leaf[1 - s];
- y->leaf[0] = 0;
- y->leaf[1] = 0;
+ VSTAILQ_INSERT_TAIL(&cool_y, y, list);
return;
}
p = &y->leaf[s];
@@ -321,21 +332,12 @@
static void
hcb_dump(struct cli *cli, const char * const *av, void *priv)
{
- struct objhead *oh, *oh2;
- struct hcb_y *y;
(void)priv;
(void)av;
cli_out(cli, "HCB dump:\n");
dumptree(cli, hcb_root.origo, 0);
cli_out(cli, "Coollist:\n");
- Lck_Lock(&hcb_mtx);
- VTAILQ_FOREACH_SAFE(oh, &laylow, coollist, oh2) {
- y = (void *)&oh->u;
- cli_out(cli, "%p ref %d, y{%u, %u}\n", oh,
- oh->refcnt, y->leaf[0], y->leaf[1]);
- }
- Lck_Unlock(&hcb_mtx);
}
static struct cli_proto hcb_cmds[] = {
@@ -348,9 +350,9 @@
static void *
hcb_cleaner(void *priv)
{
+ struct hcb_y *y, *y2;
+ struct worker ww;
struct objhead *oh, *oh2;
- struct hcb_y *y;
- struct worker ww;
memset(&ww, 0, sizeof ww);
ww.magic = WORKER_MAGIC;
@@ -358,25 +360,20 @@
THR_SetName("hcb_cleaner");
(void)priv;
while (1) {
- Lck_Lock(&hcb_mtx);
- VTAILQ_FOREACH_SAFE(oh, &laylow, coollist, oh2) {
- CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
- AZ(oh->refcnt);
- y = (void *)&oh->u;
- if (y->leaf[0] || y->leaf[1])
- continue;
- if (++oh->digest[0] > params->critbit_cooloff) {
- VTAILQ_REMOVE(&laylow, oh, coollist);
- break;
- }
+ VSTAILQ_FOREACH_SAFE(y, &dead_y, list, y2) {
+ VSTAILQ_REMOVE_HEAD(&dead_y, list);
+ FREE_OBJ(y);
}
- Lck_Unlock(&hcb_mtx);
- if (oh == NULL) {
- WRK_SumStat(&ww);
- (void)sleep(1);
- } else {
+ VTAILQ_FOREACH_SAFE(oh, &dead_h, hoh_list, oh2) {
+ VTAILQ_REMOVE(&dead_h, oh, hoh_list);
HSH_DeleteObjHead(&ww, oh);
}
+ Lck_Lock(&hcb_mtx);
+ VSTAILQ_CONCAT(&dead_y, &cool_y);
+ VTAILQ_CONCAT(&dead_h, &cool_h, hoh_list);
+ Lck_Unlock(&hcb_mtx);
+ WRK_SumStat(&ww);
+ TIM_sleep(params->critbit_cooloff);
}
NEEDLESS_RETURN(NULL);
}
@@ -393,7 +390,6 @@
CLI_AddFuncs(hcb_cmds);
Lck_New(&hcb_mtx);
AZ(pthread_create(&tp, NULL, hcb_cleaner, NULL));
- assert(sizeof(struct hcb_y) <= sizeof(oh->u));
memset(&hcb_root, 0, sizeof hcb_root);
hcb_build_bittbl();
}
@@ -411,11 +407,10 @@
if (oh->refcnt == 0) {
Lck_Lock(&hcb_mtx);
hcb_delete(&hcb_root, oh);
+ VTAILQ_INSERT_TAIL(&cool_h, oh, hoh_list);
+ Lck_Unlock(&hcb_mtx);
assert(VTAILQ_EMPTY(&oh->objcs));
assert(VTAILQ_EMPTY(&oh->waitinglist));
- oh->digest[0] = 0;
- VTAILQ_INSERT_TAIL(&laylow, oh, coollist);
- Lck_Unlock(&hcb_mtx);
}
Lck_Unlock(&oh->mtx);
#ifdef PHK
@@ -428,22 +423,28 @@
hcb_lookup(const struct sess *sp, struct objhead *noh)
{
struct objhead *oh;
- volatile unsigned u;
+ struct hcb_y *y;
+ unsigned u;
unsigned with_lock;
(void)sp;
-
+
with_lock = 0;
while (1) {
if (with_lock) {
+ if (sp->wrk->nhashpriv == NULL) {
+ ALLOC_OBJ(y, HCB_Y_MAGIC);
+ sp->wrk->nhashpriv = y;
+ }
+ AN(sp->wrk->nhashpriv);
Lck_Lock(&hcb_mtx);
VSL_stats->hcb_lock++;
assert(noh->refcnt == 1);
- oh = hcb_insert(&hcb_root, noh, 1);
+ oh = hcb_insert(sp->wrk, &hcb_root, noh, 1);
Lck_Unlock(&hcb_mtx);
} else {
VSL_stats->hcb_nolock++;
- oh = hcb_insert(&hcb_root, noh, 0);
+ oh = hcb_insert(sp->wrk, &hcb_root, noh, 0);
}
if (oh != NULL && oh == noh) {
@@ -452,7 +453,7 @@
VSL_stats->hcb_insert++;
assert(oh->refcnt > 0);
return (oh);
- }
+ }
if (oh == NULL) {
assert(!with_lock);
@@ -468,8 +469,12 @@
* under us, so fall through and try with the lock held.
*/
u = oh->refcnt;
- if (u > 0)
+ if (u > 0) {
oh->refcnt++;
+ } else {
+ assert(!with_lock);
+ with_lock = 1;
+ }
Lck_Unlock(&oh->mtx);
if (u > 0)
return (oh);
Property changes on: branches/2.1/varnish-cache/bin/varnishd/vparam.h
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishd/vparam.h:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/bin/varnishd/vparam.h:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/c00019.vtc
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/r00325.vtc
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/r00416.vtc
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/v00011.vtc
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/bin/varnishtest/tests/v00011.vtc:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/bin/varnishtest/tests/v00011.vtc:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/include/vct.h
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/include/vct.h:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/include/vct.h:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/include/vev.h
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/include/vev.h:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/include/vev.h:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/lib/libvarnish/tcp.c
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/lib/libvarnish/tcp.c:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/lib/libvarnish/tcp.c:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/lib/libvarnish/vev.c
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/lib/libvarnish/vev.c:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/lib/libvarnish/vev.c:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
Property changes on: branches/2.1/varnish-cache/lib/libvcl/vcc_dir_random.c
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/varnish-cache/lib/libvcl/vcc_dir_random.c:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
+ /trunk/varnish-cache/lib/libvcl/vcc_dir_random.c:4637,4643-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4823,4829,4842,4859-4861,4864-4868,4967-4968,4971,4973-4975,4977,4979-4981,4989
More information about the varnish-commit
mailing list