aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/srv
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2008-01-30 10:30:45 -0500
committerRuss Cox <rsc@swtch.com>2008-01-30 10:30:45 -0500
commit54dd92bebc97da7efb955f703c20cac8f4cbbb9f (patch)
tree4662b5d6e0a182b14afad3fbc49b6ba9eb558fe9 /src/cmd/venti/srv
parent0206bd5113e727870d4eb24fbd5f17843745237d (diff)
parent0206bd5113e727870d4eb24fbd5f17843745237d (diff)
downloadplan9port-54dd92bebc97da7efb955f703c20cac8f4cbbb9f.tar.gz
plan9port-54dd92bebc97da7efb955f703c20cac8f4cbbb9f.tar.bz2
plan9port-54dd92bebc97da7efb955f703c20cac8f4cbbb9f.zip
merge
Diffstat (limited to 'src/cmd/venti/srv')
-rw-r--r--src/cmd/venti/srv/bloom.c5
-rw-r--r--src/cmd/venti/srv/dat.h1
-rw-r--r--src/cmd/venti/srv/dcache.c22
-rw-r--r--src/cmd/venti/srv/disksched.c3
-rw-r--r--src/cmd/venti/srv/httpd.c1
-rw-r--r--src/cmd/venti/srv/icache.c35
-rw-r--r--src/cmd/venti/srv/icachewrite.c2
-rw-r--r--src/cmd/venti/srv/lumpcache.c7
-rw-r--r--src/cmd/venti/srv/stats.c1
-rw-r--r--src/cmd/venti/srv/utils.c8
10 files changed, 43 insertions, 42 deletions
diff --git a/src/cmd/venti/srv/bloom.c b/src/cmd/venti/srv/bloom.c
index f50c91ab..1db36bd9 100644
--- a/src/cmd/venti/srv/bloom.c
+++ b/src/cmd/venti/srv/bloom.c
@@ -198,7 +198,6 @@ int
inbloomfilter(Bloom *b, u8int *score)
{
int r;
- uint ms;
if(b == nil || b->data == nil)
return 1;
@@ -206,12 +205,10 @@ inbloomfilter(Bloom *b, u8int *score)
if(ignorebloom)
return 1;
- ms = msec();
rlock(&b->lk);
r = _inbloomfilter(b, score);
runlock(&b->lk);
- ms = ms - msec();
- addstat2(StatBloomLookup, 1, StatBloomLookupTime, ms);
+ addstat(StatBloomLookup, 1);
if(r)
addstat(StatBloomMiss, 1);
else
diff --git a/src/cmd/venti/srv/dat.h b/src/cmd/venti/srv/dat.h
index 4ed8832c..382923c7 100644
--- a/src/cmd/venti/srv/dat.h
+++ b/src/cmd/venti/srv/dat.h
@@ -637,7 +637,6 @@ enum
StatBloomLookup,
StatBloomOnes,
StatBloomBits,
- StatBloomLookupTime,
StatApartRead,
StatApartReadBytes,
diff --git a/src/cmd/venti/srv/dcache.c b/src/cmd/venti/srv/dcache.c
index abbd26a4..a50ef0c5 100644
--- a/src/cmd/venti/srv/dcache.c
+++ b/src/cmd/venti/srv/dcache.c
@@ -101,7 +101,7 @@ initdcache(u32int mem)
dcache.mem = MKNZ(u8int, (nblocks+1+128) * blocksize);
last = nil;
- p = (u8int*)(((ulong)dcache.mem+blocksize-1)&~(ulong)(blocksize-1));
+ p = (u8int*)(((uintptr)dcache.mem+blocksize-1)&~(uintptr)(blocksize-1));
for(i = 0; i < nblocks; i++){
b = &dcache.blocks[i];
b->data = &p[i * blocksize];
@@ -134,16 +134,12 @@ DBlock*
getdblock(Part *part, u64int addr, int mode)
{
DBlock *b;
- uint ms;
- ms = msec();
b = _getdblock(part, addr, mode, 1);
if(mode == OREAD || mode == ORDWR)
addstat(StatDcacheRead, 1);
if(mode == OWRITE || mode == ORDWR)
addstat(StatDcacheWrite, 1);
- ms = msec() - ms;
- addstat2(StatDcacheLookup, 1, StatDcacheLookupTime, ms);
return b;
}
@@ -151,12 +147,15 @@ DBlock*
_getdblock(Part *part, u64int addr, int mode, int load)
{
DBlock *b;
- u32int h, size;
+ u32int h, size, ms;
+ ms = 0;
trace(TraceBlock, "getdblock enter %s 0x%llux", part->name, addr);
size = part->blocksize;
if(size > dcache.size){
seterr(EAdmin, "block size %d too big for cache with size %d", size, dcache.size);
+ if(load)
+ addstat(StatDcacheLookup, 1);
return nil;
}
h = pbhash(addr);
@@ -169,7 +168,7 @@ again:
for(b = dcache.heads[h]; b != nil; b = b->next){
if(b->part == part && b->addr == addr){
if(load)
- addstat(StatDcacheHit, 1);
+ addstat2(StatDcacheHit, 1, StatDcacheLookup, 1);
goto found;
}
}
@@ -183,7 +182,12 @@ again:
return nil;
}
- addstat(StatDcacheMiss, 1);
+ /*
+ * Only start timer here, on cache miss - calling msec() on plain cache hits
+ * makes cache hits system-call bound.
+ */
+ ms = msec();
+ addstat2(StatDcacheLookup, 1, StatDcacheMiss, 1);
b = bumpdblock();
if(b == nil){
@@ -272,6 +276,8 @@ found:
b->mode = mode;
trace(TraceBlock, "getdblock exit");
+ if(ms)
+ addstat(StatDcacheLookupTime, msec() - ms);
return b;
}
diff --git a/src/cmd/venti/srv/disksched.c b/src/cmd/venti/srv/disksched.c
index 687616e1..d43b64c7 100644
--- a/src/cmd/venti/srv/disksched.c
+++ b/src/cmd/venti/srv/disksched.c
@@ -80,7 +80,8 @@ void
diskaccess(int level)
{
if(level < 0 || level >= nelem(lasttime)){
- fprint(2, "bad level in diskaccess; caller=%lux\n", getcallerpc(&level));
+ fprint(2, "bad level in diskaccess; caller=%#p\n",
+ getcallerpc(&level));
return;
}
lasttime[level] = time(0);
diff --git a/src/cmd/venti/srv/httpd.c b/src/cmd/venti/srv/httpd.c
index 5e4bbe74..623d4e47 100644
--- a/src/cmd/venti/srv/httpd.c
+++ b/src/cmd/venti/srv/httpd.c
@@ -915,7 +915,6 @@ static char* graphname[] =
"bloomlookup",
"bloomones",
"bloombits",
- "bloomlookuptime",
"apartread",
"apartreadbyte",
diff --git a/src/cmd/venti/srv/icache.c b/src/cmd/venti/srv/icache.c
index b1935d42..5875406b 100644
--- a/src/cmd/venti/srv/icache.c
+++ b/src/cmd/venti/srv/icache.c
@@ -250,6 +250,8 @@ scachemiss(u64int addr)
{
ISum *s;
+ if(!icacheprefetch)
+ return nil;
s = scachelookup(addr);
if(s == nil){
/* first time: make an entry in the cache but don't populate it yet */
@@ -439,32 +441,27 @@ insertscore(u8int score[VtScoreSize], IAddr *ia, int state, AState *as)
return 0;
}
-static int
-lookupscore_untimed(u8int score[VtScoreSize], int type, IAddr *ia)
+int
+lookupscore(u8int score[VtScoreSize], int type, IAddr *ia)
{
+ int ms, ret;
IEntry d;
- if(icachelookup(score, type, ia) >= 0)
+ if(icachelookup(score, type, ia) >= 0){
+ addstat(StatIcacheRead, 1);
return 0;
+ }
+ ms = msec();
addstat(StatIcacheFill, 1);
if(loadientry(mainindex, score, type, &d) < 0)
- return -1;
-
- insertscore(score, &d.ia, IEClean, nil);
- *ia = d.ia;
- return 0;
-}
-
-int
-lookupscore(u8int score[VtScoreSize], int type, IAddr *ia)
-{
- int ms, ret;
-
- ms = msec();
- ret = lookupscore_untimed(score, type, ia);
- ms = msec() - ms;
- addstat2(StatIcacheRead, 1, StatIcacheReadTime, ms);
+ ret = -1;
+ else{
+ ret = 0;
+ insertscore(score, &d.ia, IEClean, nil);
+ *ia = d.ia;
+ }
+ addstat2(StatIcacheRead, 1, StatIcacheReadTime, msec() - ms);
return ret;
}
diff --git a/src/cmd/venti/srv/icachewrite.c b/src/cmd/venti/srv/icachewrite.c
index 1cb9fc0e..5d8d437d 100644
--- a/src/cmd/venti/srv/icachewrite.c
+++ b/src/cmd/venti/srv/icachewrite.c
@@ -217,7 +217,7 @@ icachewriteproc(void *v)
bsize = 1<<is->blocklog;
buf = emalloc(Bufsize+bsize);
- buf = (u8int*)(((ulong)buf+bsize-1)&~(ulong)(bsize-1));
+ buf = (u8int*)(((uintptr)buf+bsize-1)&~(uintptr)(bsize-1));
for(;;){
trace(TraceProc, "icachewriteproc recv");
diff --git a/src/cmd/venti/srv/lumpcache.c b/src/cmd/venti/srv/lumpcache.c
index b989c3cb..d9a6b954 100644
--- a/src/cmd/venti/srv/lumpcache.c
+++ b/src/cmd/venti/srv/lumpcache.c
@@ -71,7 +71,7 @@ lookuplump(u8int *score, int type)
Lump *b;
u32int h;
- ms = msec();
+ ms = 0;
trace(TraceLump, "lookuplump enter");
h = hashbits(score, HashLog);
@@ -112,6 +112,9 @@ again:
CHECK(checklumpcache());
}
+ /* start timer on cache miss to avoid system call on cache hit */
+ ms = msec();
+
addstat(StatLcacheMiss, 1);
b = lumpcache.free;
lumpcache.free = b->next;
@@ -151,7 +154,7 @@ found:
addstat(StatLumpStall, -1);
trace(TraceLump, "lookuplump exit");
- addstat2(StatLcacheRead, 1, StatLcacheReadTime, msec()-ms);
+ addstat2(StatLcacheRead, 1, StatLcacheReadTime, ms ? msec()-ms : 0);
return b;
}
diff --git a/src/cmd/venti/srv/stats.c b/src/cmd/venti/srv/stats.c
index 5ee4d91f..bb944760 100644
--- a/src/cmd/venti/srv/stats.c
+++ b/src/cmd/venti/srv/stats.c
@@ -70,7 +70,6 @@ Statdesc statdesc[NStat] =
{ "bloom filter lookups", },
{ "bloom filter ones", },
{ "bloom filter bits", },
- { "bloom filter lookup time", },
{ "arena block reads", },
{ "arena block read bytes", },
diff --git a/src/cmd/venti/srv/utils.c b/src/cmd/venti/srv/utils.c
index 73c1d068..d810c53d 100644
--- a/src/cmd/venti/srv/utils.c
+++ b/src/cmd/venti/srv/utils.c
@@ -151,7 +151,7 @@ emalloc(ulong n)
}
memset(p, 0xa5, n);
setmalloctag(p, getcallerpc(&n));
-if(0)print("emalloc %p-%p by %lux\n", p, (char*)p+n, getcallerpc(&n));
+if(0)print("emalloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&n));
return p;
}
@@ -168,7 +168,7 @@ ezmalloc(ulong n)
}
memset(p, 0, n);
setmalloctag(p, getcallerpc(&n));
-if(0)print("ezmalloc %p-%p by %lux\n", p, (char*)p+n, getcallerpc(&n));
+if(0)print("ezmalloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&n));
return p;
}
@@ -182,7 +182,7 @@ erealloc(void *p, ulong n)
sysfatal("out of memory allocating %lud", n);
}
setrealloctag(p, getcallerpc(&p));
-if(0)print("erealloc %p-%p by %lux\n", p, (char*)p+n, getcallerpc(&p));
+if(0)print("erealloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&p));
return p;
}
@@ -196,7 +196,7 @@ estrdup(char *s)
t = emalloc(n);
memmove(t, s, n);
setmalloctag(t, getcallerpc(&s));
-if(0)print("estrdup %p-%p by %lux\n", t, (char*)t+n, getcallerpc(&s));
+if(0)print("estrdup %p-%p by %#p\n", t, (char*)t+n, getcallerpc(&s));
return t;
}