From 64f9764ea9f958a1abc7a32424f43019723e9e53 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 14 Jun 2008 13:28:49 -0400 Subject: vac: clean up, add unvac --- src/cmd/vac/srcload.c | 302 -------------------------------------------------- 1 file changed, 302 deletions(-) delete mode 100644 src/cmd/vac/srcload.c (limited to 'src/cmd/vac/srcload.c') diff --git a/src/cmd/vac/srcload.c b/src/cmd/vac/srcload.c deleted file mode 100644 index 8f3b2a0c..00000000 --- a/src/cmd/vac/srcload.c +++ /dev/null @@ -1,302 +0,0 @@ -#include "stdinc.h" -#include -#include "vac.h" -#include "dat.h" -#include "fns.h" -#include "error.h" - -int num = 1000; -int length = 20*1024; -int block= 1024; -int bush = 4; -int iter = 10000; -Biobuf *bout; -int maxdepth; - -Source *mkroot(Cache*); -void new(Source*, int trace, int); -int delete(Source*); -void dump(Source*, int indent, ulong nentry); -void dumpone(Source *s); -int count(Source *s, int); -void stats(Source *s); - -void -main(int argc, char *argv[]) -{ - int i; - Cache *c; - char *host = nil; - VtSession *z; - int csize = 10000; - Source *r; - ulong t; - - t = time(0); - fprint(1, "time = %lud\n", t); - - srand(t); - - ARGBEGIN{ - case 'i': - iter = atoi(ARGF()); - break; - case 'n': - num = atoi(ARGF()); - break; - case 'l': - length = atoi(ARGF()); - break; - case 'b': - block = atoi(ARGF()); - break; - case 'h': - host = ARGF(); - break; - case 'u': - bush = atoi(ARGF()); - break; - case 'c': - csize = atoi(ARGF()); - break; - }ARGEND; - - vtAttach(); - - bout = vtMemAllocZ(sizeof(Biobuf)); - Binit(bout, 1, OWRITE); - - fmtinstall('V', vtScoreFmt); - fmtinstall('R', vtErrFmt); - - z = vtDial(host); - if(z == nil) - vtFatal("could not connect to server: %s", vtGetError()); - - if(!vtConnect(z, 0)) - sysfatal("vtConnect: %r"); - - c = cacheAlloc(z, block, csize); - r = mkroot(c); - for(i=0; ilump, 0); - sourceRemove(r); - cacheCheck(c); - - vtClose(z); - vtDetach(); - - exits(0); -} - - -Source * -mkroot(Cache *c) -{ - Lump *u; - VtEntry *dir; - Source *r; - - u = cacheAllocLump(c, VtDirType, cacheGetBlockSize(c), 1); - dir = (VtEntry*)u->data; - vtPutUint16(dir->psize, cacheGetBlockSize(c)); - vtPutUint16(dir->dsize, cacheGetBlockSize(c)); - dir->flag = VtEntryActive|VtEntryDir; - memmove(dir->score, vtZeroScore, VtScoreSize); - - r = sourceAlloc(c, u, 0, 0); - vtUnlock(u->lk); - if(r == nil) - sysfatal("could not create root source: %r"); - return r; -} - -void -new(Source *s, int trace, int depth) -{ - int i, n; - Source *ss; - - if(depth > maxdepth) - maxdepth = depth; - - n = sourceGetDirSize(s); - for(i=0; idir && frand() < 1./bush) { - if(trace) { - int j; - for(j=0; jpsize, s->dsize, 1+frand()>.5, 0); - if(ss == nil) - fprint(2, "could not create directory: %r\n"); - if(trace) { - int j; - for(j=1; jentry, ss->lump->score); - } - sourceFree(ss); -} - -int -delete(Source *s) -{ - int i, n; - Source *ss; - - assert(s->dir); - - n = sourceGetDirSize(s); - /* check if empty */ - for(i=0; idir && delete(ss)) { - sourceFree(ss); - return 1; - } - if(1) - break; - sourceFree(ss); - } - - - sourceRemove(ss); - return 1; -} - -void -dumpone(Source *s) -{ - ulong i, n; - Source *ss; - - Bprint(bout, "gen %4lud depth %d %V", s->gen, s->depth, s->lump->score); - if(!s->dir) { - Bprint(bout, " data size: %llud\n", s->size); - return; - } - n = sourceGetDirSize(s); - Bprint(bout, " dir size: %lud\n", n); - for(i=0; idir, ss->size, ss->lump->score); - sourceFree(ss); - } - return; -} - - -void -dump(Source *s, int ident, ulong entry) -{ - ulong i, n; - Source *ss; - - for(i=0; igen, s->depth); - if(!s->dir) { - Bprint(bout, " data size: %llud\n", s->size); - return; - } - n = sourceGetDirSize(s); - Bprint(bout, " dir size: %lud\n", n); - for(i=0; idir) - return 0; - n = sourceGetDirSize(s); - c = 0; - for(i=0; i max) - max = c; - sourceFree(ss); - } -fprint(2, "count = %d top = %d depth=%d maxcount %d\n", cc, n, maxdepth, max); -} -- cgit v1.2.3