merge
This commit is contained in:
commit
54dd92bebc
12 changed files with 50 additions and 48 deletions
|
|
@ -54,9 +54,9 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
BEGIN Normal; /* Starts yylex off in the right state */
|
|
||||||
if (argc==1) {
|
if (argc==1) {
|
||||||
yyin = stdin;
|
yyin = stdin;
|
||||||
|
BEGIN Normal; /* Starts yylex off in the right state */
|
||||||
yylex();
|
yylex();
|
||||||
}
|
}
|
||||||
else for (i=1; i<argc; i++) {
|
else for (i=1; i<argc; i++) {
|
||||||
|
|
@ -65,6 +65,7 @@ main(int argc, char **argv)
|
||||||
fprintf(stderr,"can't open %s\n",argv[i]);
|
fprintf(stderr,"can't open %s\n",argv[i]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
BEGIN Normal; /* Starts yylex off in the right state */
|
||||||
yylex();
|
yylex();
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,6 @@ int
|
||||||
inbloomfilter(Bloom *b, u8int *score)
|
inbloomfilter(Bloom *b, u8int *score)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
uint ms;
|
|
||||||
|
|
||||||
if(b == nil || b->data == nil)
|
if(b == nil || b->data == nil)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -206,12 +205,10 @@ inbloomfilter(Bloom *b, u8int *score)
|
||||||
if(ignorebloom)
|
if(ignorebloom)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
ms = msec();
|
|
||||||
rlock(&b->lk);
|
rlock(&b->lk);
|
||||||
r = _inbloomfilter(b, score);
|
r = _inbloomfilter(b, score);
|
||||||
runlock(&b->lk);
|
runlock(&b->lk);
|
||||||
ms = ms - msec();
|
addstat(StatBloomLookup, 1);
|
||||||
addstat2(StatBloomLookup, 1, StatBloomLookupTime, ms);
|
|
||||||
if(r)
|
if(r)
|
||||||
addstat(StatBloomMiss, 1);
|
addstat(StatBloomMiss, 1);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,6 @@ enum
|
||||||
StatBloomLookup,
|
StatBloomLookup,
|
||||||
StatBloomOnes,
|
StatBloomOnes,
|
||||||
StatBloomBits,
|
StatBloomBits,
|
||||||
StatBloomLookupTime,
|
|
||||||
|
|
||||||
StatApartRead,
|
StatApartRead,
|
||||||
StatApartReadBytes,
|
StatApartReadBytes,
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ initdcache(u32int mem)
|
||||||
dcache.mem = MKNZ(u8int, (nblocks+1+128) * blocksize);
|
dcache.mem = MKNZ(u8int, (nblocks+1+128) * blocksize);
|
||||||
|
|
||||||
last = nil;
|
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++){
|
for(i = 0; i < nblocks; i++){
|
||||||
b = &dcache.blocks[i];
|
b = &dcache.blocks[i];
|
||||||
b->data = &p[i * blocksize];
|
b->data = &p[i * blocksize];
|
||||||
|
|
@ -134,16 +134,12 @@ DBlock*
|
||||||
getdblock(Part *part, u64int addr, int mode)
|
getdblock(Part *part, u64int addr, int mode)
|
||||||
{
|
{
|
||||||
DBlock *b;
|
DBlock *b;
|
||||||
uint ms;
|
|
||||||
|
|
||||||
ms = msec();
|
|
||||||
b = _getdblock(part, addr, mode, 1);
|
b = _getdblock(part, addr, mode, 1);
|
||||||
if(mode == OREAD || mode == ORDWR)
|
if(mode == OREAD || mode == ORDWR)
|
||||||
addstat(StatDcacheRead, 1);
|
addstat(StatDcacheRead, 1);
|
||||||
if(mode == OWRITE || mode == ORDWR)
|
if(mode == OWRITE || mode == ORDWR)
|
||||||
addstat(StatDcacheWrite, 1);
|
addstat(StatDcacheWrite, 1);
|
||||||
ms = msec() - ms;
|
|
||||||
addstat2(StatDcacheLookup, 1, StatDcacheLookupTime, ms);
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,12 +147,15 @@ DBlock*
|
||||||
_getdblock(Part *part, u64int addr, int mode, int load)
|
_getdblock(Part *part, u64int addr, int mode, int load)
|
||||||
{
|
{
|
||||||
DBlock *b;
|
DBlock *b;
|
||||||
u32int h, size;
|
u32int h, size, ms;
|
||||||
|
|
||||||
|
ms = 0;
|
||||||
trace(TraceBlock, "getdblock enter %s 0x%llux", part->name, addr);
|
trace(TraceBlock, "getdblock enter %s 0x%llux", part->name, addr);
|
||||||
size = part->blocksize;
|
size = part->blocksize;
|
||||||
if(size > dcache.size){
|
if(size > dcache.size){
|
||||||
seterr(EAdmin, "block size %d too big for cache with size %d", 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;
|
return nil;
|
||||||
}
|
}
|
||||||
h = pbhash(addr);
|
h = pbhash(addr);
|
||||||
|
|
@ -169,7 +168,7 @@ again:
|
||||||
for(b = dcache.heads[h]; b != nil; b = b->next){
|
for(b = dcache.heads[h]; b != nil; b = b->next){
|
||||||
if(b->part == part && b->addr == addr){
|
if(b->part == part && b->addr == addr){
|
||||||
if(load)
|
if(load)
|
||||||
addstat(StatDcacheHit, 1);
|
addstat2(StatDcacheHit, 1, StatDcacheLookup, 1);
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -183,7 +182,12 @@ again:
|
||||||
return nil;
|
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();
|
b = bumpdblock();
|
||||||
if(b == nil){
|
if(b == nil){
|
||||||
|
|
@ -272,6 +276,8 @@ found:
|
||||||
|
|
||||||
b->mode = mode;
|
b->mode = mode;
|
||||||
trace(TraceBlock, "getdblock exit");
|
trace(TraceBlock, "getdblock exit");
|
||||||
|
if(ms)
|
||||||
|
addstat(StatDcacheLookupTime, msec() - ms);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,8 @@ void
|
||||||
diskaccess(int level)
|
diskaccess(int level)
|
||||||
{
|
{
|
||||||
if(level < 0 || level >= nelem(lasttime)){
|
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;
|
return;
|
||||||
}
|
}
|
||||||
lasttime[level] = time(0);
|
lasttime[level] = time(0);
|
||||||
|
|
|
||||||
|
|
@ -915,7 +915,6 @@ static char* graphname[] =
|
||||||
"bloomlookup",
|
"bloomlookup",
|
||||||
"bloomones",
|
"bloomones",
|
||||||
"bloombits",
|
"bloombits",
|
||||||
"bloomlookuptime",
|
|
||||||
|
|
||||||
"apartread",
|
"apartread",
|
||||||
"apartreadbyte",
|
"apartreadbyte",
|
||||||
|
|
|
||||||
|
|
@ -250,6 +250,8 @@ scachemiss(u64int addr)
|
||||||
{
|
{
|
||||||
ISum *s;
|
ISum *s;
|
||||||
|
|
||||||
|
if(!icacheprefetch)
|
||||||
|
return nil;
|
||||||
s = scachelookup(addr);
|
s = scachelookup(addr);
|
||||||
if(s == nil){
|
if(s == nil){
|
||||||
/* first time: make an entry in the cache but don't populate it yet */
|
/* 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
lookupscore_untimed(u8int score[VtScoreSize], int type, IAddr *ia)
|
|
||||||
{
|
|
||||||
IEntry d;
|
|
||||||
|
|
||||||
if(icachelookup(score, type, ia) >= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
addstat(StatIcacheFill, 1);
|
|
||||||
if(loadientry(mainindex, score, type, &d) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
insertscore(score, &d.ia, IEClean, nil);
|
|
||||||
*ia = d.ia;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
lookupscore(u8int score[VtScoreSize], int type, IAddr *ia)
|
lookupscore(u8int score[VtScoreSize], int type, IAddr *ia)
|
||||||
{
|
{
|
||||||
int ms, ret;
|
int ms, ret;
|
||||||
|
IEntry d;
|
||||||
|
|
||||||
|
if(icachelookup(score, type, ia) >= 0){
|
||||||
|
addstat(StatIcacheRead, 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ms = msec();
|
ms = msec();
|
||||||
ret = lookupscore_untimed(score, type, ia);
|
addstat(StatIcacheFill, 1);
|
||||||
ms = msec() - ms;
|
if(loadientry(mainindex, score, type, &d) < 0)
|
||||||
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ icachewriteproc(void *v)
|
||||||
|
|
||||||
bsize = 1<<is->blocklog;
|
bsize = 1<<is->blocklog;
|
||||||
buf = emalloc(Bufsize+bsize);
|
buf = emalloc(Bufsize+bsize);
|
||||||
buf = (u8int*)(((ulong)buf+bsize-1)&~(ulong)(bsize-1));
|
buf = (u8int*)(((uintptr)buf+bsize-1)&~(uintptr)(bsize-1));
|
||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
trace(TraceProc, "icachewriteproc recv");
|
trace(TraceProc, "icachewriteproc recv");
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ lookuplump(u8int *score, int type)
|
||||||
Lump *b;
|
Lump *b;
|
||||||
u32int h;
|
u32int h;
|
||||||
|
|
||||||
ms = msec();
|
ms = 0;
|
||||||
trace(TraceLump, "lookuplump enter");
|
trace(TraceLump, "lookuplump enter");
|
||||||
|
|
||||||
h = hashbits(score, HashLog);
|
h = hashbits(score, HashLog);
|
||||||
|
|
@ -112,6 +112,9 @@ again:
|
||||||
CHECK(checklumpcache());
|
CHECK(checklumpcache());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* start timer on cache miss to avoid system call on cache hit */
|
||||||
|
ms = msec();
|
||||||
|
|
||||||
addstat(StatLcacheMiss, 1);
|
addstat(StatLcacheMiss, 1);
|
||||||
b = lumpcache.free;
|
b = lumpcache.free;
|
||||||
lumpcache.free = b->next;
|
lumpcache.free = b->next;
|
||||||
|
|
@ -151,7 +154,7 @@ found:
|
||||||
addstat(StatLumpStall, -1);
|
addstat(StatLumpStall, -1);
|
||||||
|
|
||||||
trace(TraceLump, "lookuplump exit");
|
trace(TraceLump, "lookuplump exit");
|
||||||
addstat2(StatLcacheRead, 1, StatLcacheReadTime, msec()-ms);
|
addstat2(StatLcacheRead, 1, StatLcacheReadTime, ms ? msec()-ms : 0);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,6 @@ Statdesc statdesc[NStat] =
|
||||||
{ "bloom filter lookups", },
|
{ "bloom filter lookups", },
|
||||||
{ "bloom filter ones", },
|
{ "bloom filter ones", },
|
||||||
{ "bloom filter bits", },
|
{ "bloom filter bits", },
|
||||||
{ "bloom filter lookup time", },
|
|
||||||
|
|
||||||
{ "arena block reads", },
|
{ "arena block reads", },
|
||||||
{ "arena block read bytes", },
|
{ "arena block read bytes", },
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ emalloc(ulong n)
|
||||||
}
|
}
|
||||||
memset(p, 0xa5, n);
|
memset(p, 0xa5, n);
|
||||||
setmalloctag(p, getcallerpc(&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;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,7 +168,7 @@ ezmalloc(ulong n)
|
||||||
}
|
}
|
||||||
memset(p, 0, n);
|
memset(p, 0, n);
|
||||||
setmalloctag(p, getcallerpc(&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;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ erealloc(void *p, ulong n)
|
||||||
sysfatal("out of memory allocating %lud", n);
|
sysfatal("out of memory allocating %lud", n);
|
||||||
}
|
}
|
||||||
setrealloctag(p, getcallerpc(&p));
|
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;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ estrdup(char *s)
|
||||||
t = emalloc(n);
|
t = emalloc(n);
|
||||||
memmove(t, s, n);
|
memmove(t, s, n);
|
||||||
setmalloctag(t, getcallerpc(&s));
|
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;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ int swizzle;
|
||||||
int flush;
|
int flush;
|
||||||
int abase=2;
|
int abase=2;
|
||||||
int xd(char *, int);
|
int xd(char *, int);
|
||||||
void xprint(char *, long);
|
void xprint(char *, ulong);
|
||||||
void initarg(void), swizz(void);
|
void initarg(void), swizz(void);
|
||||||
enum{
|
enum{
|
||||||
Narg=10
|
Narg=10
|
||||||
|
|
@ -297,7 +297,7 @@ fmt2(char *f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<ndata; i+=sizeof(unsigned long))
|
for(i=0; i<ndata; i+=sizeof(unsigned long))
|
||||||
xprint(f, (data[i]<<24)|(data[i+1]<<16)|(data[i+2]<<8)|data[i+3]);
|
xprint(f, (u32int)((data[i]<<24)|(data[i+1]<<16)|(data[i+2]<<8)|data[i+3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -346,7 +346,7 @@ fmtc(char *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xprint(char *fmt, long d)
|
xprint(char *fmt, ulong d)
|
||||||
{
|
{
|
||||||
if(Bprint(&bout, fmt, d)<0){
|
if(Bprint(&bout, fmt, d)<0){
|
||||||
fprint(2, "xd: i/o error\n");
|
fprint(2, "xd: i/o error\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue