changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > ventivac / changeset: serve statistics on /chan/vcachestats, do not periodially print statistics anymore.

changeset 52: b2aa6f915c71
parent 51: bbec64af3100
child 53: a85e74e20558
author: Mechiel Lukkien <mechiel@ueber.net>
date: Fri, 13 Jul 2007 12:44:19 +0200
files: appl/cmd/vcache.b man/1/vcache
description: serve statistics on /chan/vcachestats, do not periodially print statistics anymore.
     1.1--- a/appl/cmd/vcache.b	Thu Jul 12 16:37:43 2007 +0200
     1.2+++ b/appl/cmd/vcache.b	Fri Jul 13 12:44:19 2007 +0200
     1.3@@ -33,7 +33,11 @@
     1.4 	init:	fn(nil: ref Draw->Context, args: list of string);
     1.5 };
     1.6 
     1.7+Eperm:	con "permission denied";
     1.8+
     1.9 laddr := "net!*!venti";
    1.10+statsdir := "/chan/";
    1.11+statsfile := "vcachestats";
    1.12 dflag := nflag := vflag := wflag := 0;
    1.13 
    1.14 maxcachesize := 0;
    1.15@@ -79,13 +83,18 @@
    1.16 	venti->init();
    1.17 
    1.18 	arg->init(args);
    1.19-	arg->setusage(arg->progname()+" [-dnvw] [-a laddr] [-s size] remoteaddr [proxyaddr]");
    1.20+	arg->setusage(arg->progname()+" [-dnvw] [-a laddr] [-s size] [-S statsfile] remoteaddr [proxyaddr]");
    1.21 	while((c := arg->opt()) != 0)
    1.22 		case c {
    1.23 		'a' =>	laddr = arg->earg();
    1.24 		'd' =>	dflag++;
    1.25 		'n' =>	nflag++;
    1.26 		's' =>	maxcachesize = int arg->earg();
    1.27+		'S' =>	(statsdir, statsfile) = str->splitstrr(arg->earg(), "/");
    1.28+			if(statsfile == nil) {
    1.29+				fprint(fildes(2), "bad statsfile\n");
    1.30+				arg->usage();
    1.31+			}
    1.32 		'v' =>	vflag++;
    1.33 		'w' =>	wflag = 1;
    1.34 		* =>	fprint(fildes(2), "bad option: -%c\n", c);
    1.35@@ -434,9 +443,12 @@
    1.36 	bogusreqc := chan of (ref Vmsg, int);
    1.37 	reqc := requestc;
    1.38 
    1.39-	tickch := chan of int;
    1.40-	if(dflag)
    1.41-		spawn tick(tickch);
    1.42+	fio := sys->file2chan(statsdir, statsfile);
    1.43+	if(fio == nil) {
    1.44+		fprint(fildes(2), "file2chan: %r;  not serving statistics\n");
    1.45+		fio = ref sys->FileIO(chan of (int, int, int, sys->Rread), chan of (int, array of byte, int, sys->Rwrite));
    1.46+	} else
    1.47+		if(dflag) debug(sprint("file2chan: serving %s%s", statsdir, statsfile));
    1.48 
    1.49 	debug("central: beginning loop");
    1.50 	initheap := heapused();
    1.51@@ -453,6 +465,33 @@
    1.52 		if(dflag) debug(sprint("central: ALT rclaim=%d pclaim=%d rfree=%d pfree=%d",
    1.53 			remote.claimed, proxy.claimed, remote.tidsfree(), proxy.tidsfree()));
    1.54 		alt {
    1.55+		(offset, nil, nil, rc) := <- fio.read =>
    1.56+			if(rc == nil)
    1.57+				continue;
    1.58+
    1.59+			buf := array of byte sprint(
    1.60+				"%14d clients\n%14d proxy connection\n%14d proxy transitops\n%14d remote connection\n%14d remote transitops\n"+
    1.61+				"%14d maxcachesize\n%14d cacheheads\n%14d cacheused\n"+
    1.62+				"%14d cachemiss\n%14d cachehit\n%14d cacherequest\n"+
    1.63+				"%14d proxymiss\n%14d proxyhit\n%14d proxyrequest\n"+
    1.64+				"%14d remotereads\n%14d remotewrites\n"+
    1.65+				"%14d heapused\n",
    1.66+				len clients, proxy.fd != nil, 256-proxy.tidsfree(), remote.fd != nil, 256-remote.tidsfree(),
    1.67+				maxcachesize, len cacheheads, cacheused,
    1.68+				cachemiss, cachereq-cachemiss, cachereq,
    1.69+				proxymiss, proxyreq-proxymiss, proxyreq,
    1.70+				remotereads, remotewrites, heapused()-initheap);
    1.71+
    1.72+			if(offset > len buf)
    1.73+				offset = len buf;
    1.74+			rc <-= (buf[offset:], nil);
    1.75+
    1.76+		(nil, nil, nil, wc) := <- fio.write =>
    1.77+			if(wc == nil)
    1.78+				continue;
    1.79+			if(dflag) debug("main: file2chan write");
    1.80+			wc <-= (0, Eperm);
    1.81+
    1.82 		(rpid, wpid, respc) := <- registerc =>
    1.83 			verbose("central: new client");
    1.84 			clientput(rpid, wpid, respc);
    1.85@@ -661,12 +700,6 @@
    1.86 		<- remote.errorc =>
    1.87 			verbose("central: remote writer error");
    1.88 			remote.close(proxy);
    1.89-
    1.90-		<- tickch =>
    1.91-			debug(sprint("cachemiss=%d cachehit=%d cacherequest=%d", cachemiss, cachereq-cachemiss, cachereq));
    1.92-			debug(sprint("proxymiss=%d proxyhit=%d proxyrequest=%d", proxymiss, proxyreq-proxymiss, proxyreq));
    1.93-			debug(sprint("remotereads=%d remotewrites=%d", remotereads, remotewrites));
    1.94-			debug(sprint("heapused=%d", heapused()-initheap));
    1.95 		}
    1.96 	}
    1.97 }
     2.1--- a/man/1/vcache	Thu Jul 12 16:37:43 2007 +0200
     2.2+++ b/man/1/vcache	Fri Jul 13 12:44:19 2007 +0200
     2.3@@ -11,6 +11,9 @@
     2.4 ] [
     2.5 .B -s
     2.6 .I size
     2.7+] [
     2.8+.B -S
     2.9+.I statsfile
    2.10 ]
    2.11 .I remoteaddr
    2.12 [
    2.13@@ -31,6 +34,11 @@
    2.14 .BI -s " size"
    2.15 Size of the in-memory cache in bytes.  The overhead of the score and data structures is included in the size.  Default is 0 bytes.
    2.16 .TP
    2.17+.BI -S " statsfile"
    2.18+File to serve statistics on.  Default is
    2.19+.IR /chan/vcachestats .
    2.20+Each line starts with a space-padded 14 byte number followed by a space and a textual description.
    2.21+.TP
    2.22 .B -n
    2.23 Do not check the results of the proxy and authoritative server.  By default, vcache verifies the returned data and scores.
    2.24 .TP