From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: erik quanstrom Date: Fri, 20 Feb 2009 10:41:15 -0500 To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-lapamodbwoeunjpsupexazrzfq" Subject: Re: [9fans] Calling vac from C Topicbox-Message-UUID: a4a7e366-ead4-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-lapamodbwoeunjpsupexazrzfq Content-Disposition: inline Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit > I believe that > 1) Its too much trouble parsing the output everytime. i don't buy that. that takes very little code. since you have evidently already written the code, the cost is zero. (if you're worried about runtime, i measure parsing time at 338ns on a core i7 920. cf. attached digestspd.c) > 2) Calling some function from an included library will be faster. maybe. are you sure that it matters? i measure base fork/exec latency on a 1.8ghz xeon5000 at 330µs. (files served from the fileserver, not a ram disk.) the attached fork.c and nop.c were used to do the measurement. i measure vac throughput at ~3mb/s for small files from a brand new venti running from a ramdisk. the venti was tiny with 5mb isect and 100mb arenas, and empty. at that rate, 330µs will cost you 1038 bytes, or 0.3%. remember that dynamic linking isn't free. that cost assumes that dynamic linking is free, and it is not. - erik --upas-lapamodbwoeunjpsupexazrzfq Content-Disposition: attachment; filename=digestspd.c Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #include #include #include static int nibble(int c) { if(c >= '0' && c <= '9') return c - '0'; if(c < 0x20) c += 0x20; if(c >= 'a' && c <= 'f') return c - 'a'+10; return 0xff; } static void bindigest(char *s, uchar *t) { int i; if(strlen(s) != 2*SHA1dlen) sysfatal("bad digest %s", s); for(i = 0; i < SHA1dlen; i++) t[i] = nibble(s[2*i])<<4 | nibble(s[2*i + 1]); } static char *vs = "vac:da6b4b5549383cffc1b5691d824fc4bd381f0f6b"; void main(void) { int i, n; uchar score[SHA1dlen]; uvlong t0, t1; n = 1000*1000; t0 = nsec(); for(i = 0; i < n; i++){ if(strncmp(vs, "vac:", 4) == 0) bindigest(vs + 4, score); else sysfatal("bad digest"); } t1 = nsec(); print("%g\n", 1.*(t1 - t0)/(1.*n)); exits(""); } --upas-lapamodbwoeunjpsupexazrzfq Content-Disposition: attachment; filename=fork.c Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #include #include char *argv[] = {"nop", 0}; void main(void) { int i, n; uvlong t0, t1; n = 10000; t0 = nsec(); for(i = 0; i < n; i++) switch(fork()){ case 0: exec(*argv, argv); _exits("exec"); case -1: sysfatal("fork"); default: free(wait()); } t1 = nsec(); print("%g\n", 1.*(t1 - t0)/(1.*n)); exits(""); } --upas-lapamodbwoeunjpsupexazrzfq Content-Disposition: attachment; filename=nop.c Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #include #include void main(void) { exits(""); } --upas-lapamodbwoeunjpsupexazrzfq--