History

added timing tests

John (EBo) David committed 15 years ago

Commit e515cea1 parent c15253c1 file · +93 −17Browse files

Unified · Split

sys/src/cmd/uem/gangfs.c+93−17
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #include <libsec.h>
2525 #include <stdio.h>
2626 #include "debug.h"
27+#include "timeit.h"
2728
2829 int remote_override = 0;
2930 int remote = 0;
@@ -534,7 +535,7 @@ static int · 504 unmodified lines
534535 checkmount(char *addr)
535536 {
536537 char *dest = estrdup9p(addr);
537− int retries = 0;
538+ int retries;
538539 int err = 0;
539540 int fd;
540541 char *srvpt = smprint("/srv/%s", addr);
@@ -568,10 +569,31 @@ checkmount(char *addr) · 27 unmodified lines
568569
569570 /* no dir, spawn off an import */
570571 DPRINT(DNET, "\tno dir, spawn off an import +++\n");
572+/*
573+ for (retries=0, err=-1; retries<=5000; retries++){
574+ if(0==retries%1000)
575+ proccreate(startimport, dest, STACK);
576+
577+ // we need to wait for this to be done
578+ if((tmp = dirstat(mtpt)) == nil){
579+ err = 0;
580+ break;
581+ }
582+
583+ // ugh, arbitrary delay
584+ sleep(10);
585+ }
586+ if(err)
587+ DPRINT(DERR, "*ERROR*: checkmount: import for (%s) not complete after 10 seconds, giving up\n", dest);
588+*/
589+
590+
591+
592+for (retries=0, tmp=nil; retries<=5 && tmp==nil; retries++){
571593 proccreate(startimport, dest, STACK);
572594
573− /* we need to wait for this to be done */
574− while((tmp = dirstat(mtpt)) == nil) { /* ugh, arbitrary 100ms delay */
595+ // we need to wait for this to be done
596+ while((tmp = dirstat(mtpt)) == nil) { // ugh, arbitrary 100ms delay
575597 if(retries++ > 1009) {
576598 DPRINT(DERR, "*ERROR*: checkmount: import for (%s) not complete after 10 seconds, giving up\n", dest);
577599 err = -1;
@@ -579,6 +601,7 @@ checkmount(char *addr) · 1 unmodified line
579601 }
580602 sleep(10);
581603 }
604+}
582605
583606 out:
584607 if(srvpt)
@@ -993,6 +1016,9 @@ releasegang(Gang *g) · 408 unmodified lines
9931016 }
9941017
9951018 wunlock(&glock);
1019+
1020+ // FIXME: dump the time stamps
1021+ timeit_dump();
9961022 }
9971023
9981024 static void
@@ -1328,7 +1354,9 @@ setupstdio(Session *s) · 329 unmodified lines
13281354
13291355 snprint(dest, 255, "%s/g%d/%d", gangpath, g->index, s->index);
13301356
1357+if(!s->remote)stamp("Before local bind");
13311358 n = bind(buf, dest, MREPL);
1359+if(!s->remote)timeit_tag_dt_float("Before local bind", "Time for local bind");
13321360 DPRINT(DEXE, "\tbind buf=(%s) dest=(%s) ret=%d\n", buf, dest, n);
13331361 if(n < 0)
13341362 return smprint("couldn't bind %s %s: %r\n", buf, dest);
@@ -1341,7 +1369,9 @@ setupstdio(Session *s) · 6 unmodified lines
13411369
13421370 snprint(dest, 255, "%s/g%d/stdin", xgangpath, g->index);
13431371 DPRINT(DEXE, "\tsplicefrom buf=(%s) dest=(%s)\n", buf, dest);
1372+if(!s->remote)stamp("Before local splicefrom/stdin");
13441373 n = splicefrom(buf, dest); /* execfs initiates splicefrom gangfs */
1374+if(!s->remote)timeit_tag_dt_float("Before local splicefrom/stdin", "Time for local splicefrom/stdin");
13451375 DPRINT(DEXE, "\t\tret=%d\n", n);
13461376 if(n < 0)
13471377 return smprint("setupstdio: %r\n");
@@ -1354,7 +1384,9 @@ setupstdio(Session *s) · 6 unmodified lines
13541384
13551385 snprint(dest, 255, "%s/g%d/stdout", xgangpath, g->index);
13561386 DPRINT(DEXE, "\tspliceto buf=(%s) dest=(%s)\n", buf, dest);
1387+if(!s->remote)stamp("Before local spliceto/stdout");
13571388 n = spliceto(buf, dest); /* execfs initiates spliceto gangfs stdout */
1389+if(!s->remote)timeit_tag_dt_float("Before local spliceto/stdout", "Time for local spliceto/stdout");
13581390 DPRINT(DEXE, "\t\tret=%d\n", n);
13591391 if(n < 0)
13601392 return smprint("setupstdio: %r\n");
@@ -1367,11 +1399,14 @@ setupstdio(Session *s) · 6 unmodified lines
13671399
13681400 snprint(dest, 255, "%s/g%d/stderr", xgangpath, g->index);
13691401 DPRINT(DEXE, "\tspliceto buf=(%s) dest=(%s)\n", buf, dest);
1402+if(!s->remote)stamp("Before local spliceto/stderr");
13701403 n = spliceto(buf, dest); /* execfs initiates spliceto gangfs stderr */
1404+if(!s->remote)timeit_tag_dt_float("Before local spliceto/stderr", "Time for local spliceto/stderr");
13711405 DPRINT(DEXE, "\t\tret=%d\n", n);
13721406 if(n < 0)
13731407 return smprint("setupstdio: %r\n");
13741408
1409+if(!s->remote)timeit_tag_dt_float("Before local bind", "Time for local setupstdio");
13751410 return nil;
13761411 }
13771412
@@ -1386,22 +1421,27 @@ cloneproc(void *arg) · 8 unmodified lines
13861421 int n = -1;
13871422 char *err;
13881423
1389− if(sess->remote)
1424+ if(sess->remote){
13901425 snprint(buf, 255, "%s/gclone", sess->path);
1391− else
1426+//stamp("gclone");
1427+ }else{
13921428 snprint(buf, 255, "%s/clone", sess->path);
1429+stamp("clone");
1430+ }
13931431
13941432 DPRINT(DEXE, "cloneproc: **** clone proc %s (remote=%d)\n",
13951433 buf, sess->remote);
13961434
13971435 /* FUTURE: This shouldn't be necessary with exec2fs */
1398− for(retries=0; retries <= 50; retries++) {
1436+if(!sess->remote)stamp("Before sess");
1437+ for(retries=0; retries <= 10; retries++) {
13991438 sess->fd = open(buf, ORDWR);
14001439
14011440 if(sess->fd <= 0) {
1402− sleep(100);
1403− DPRINT(DERR, "WARNING: retry: %d on %d:%d opening exec2fs returned %d: %r -- retrying\n",
1404− retries, sess->index, sess->subindex, sess->fd);
1441+stamp("sess sleep1");
1442+ sleep(0);
1443+ DPRINT(DERR, "WARNING: retry: %d opening execfs returned %d: %r -- retrying\n",
1444+ retries, sess->fd);
14051445 continue;
14061446 }
14071447
@@ -1410,13 +1450,16 @@ cloneproc(void *arg) · 2 unmodified lines
14101450 buf[n] = 0;
14111451 break;
14121452 }
1453+stamp("sess sleep2");
14131454
1414− sleep(100);
1415− DPRINT(DERR, "WARNING: retry: %d exec2fs's pread=(%d) failed for fd=(%d): %r -- retrying\n",
1455+ sleep(0);
1456+ DPRINT(DERR, "WARNING: retry: %d execfs's pread=(%d) failed for fd=(%d): %r -- retrying\n",
14161457 retries, n, sess->fd);
14171458 close(sess->fd);
14181459 }
14191460
1461+if(!sess->remote)timeit_tag_dt_float("Before sess", "Time for local sess");
1462+
14201463 DPRINT(DEXE, "\tcontrol channel on sess->fd=(%d) for subsession (%d) pread=(%d)\n",
14211464 sess->fd, sess->subindex, n);
14221465
@@ -1441,6 +1484,7 @@ cloneproc(void *arg) · 18 unmodified lines
14411484 DPRINT(DEXE, "cloneproc: sess->pid=%ld buf=(%s)\n", sess->pid, buf);
14421485
14431486 /* if we are a remote session, setup backmount */
1487+//stamp("Before remote");
14441488 if(sess->remote) {
14451489 DPRINT(DEXE, "Attempting to remote checkmount %s on %s\n",
14461490 mysysname, sess->path);
@@ -1472,6 +1516,7 @@ cloneproc(void *arg) · 25 unmodified lines
14721516 }
14731517
14741518 /* finish by setting up stdio */
1519+if(!sess->remote)stamp("Before local setupstdio");
14751520 if(err = setupstdio(sess)) {
14761521 DPRINT(DEXE, "reporting failure from stdio setup session %d:%d: %s\n",
14771522 sess->index, sess->subindex, err);
@@ -1480,6 +1525,7 @@ cloneproc(void *arg) · 2 unmodified lines
14801525 DPRINT(DEXE, "reporting success from session %d:%d\n", sess->index, sess->subindex);
14811526 sendp(sess->chan, nil);
14821527 }
1528+if(!sess->remote)timeit_tag_dt_float("Before local setupstdio", "Time for local setupstdio outer");
14831529
14841530 error:
14851531 threadexits(nil);
@@ -1525,9 +1571,13 @@ reslocal(Gang *g) · 39 unmodified lines
15251571 g->sess = emalloc9p(sizeof(Session)*g->size);
15261572
15271573 for(count = 0; count < g->size; count++) {
1574+stamp("Before local setupsession");
15281575 setupsess(g, &g->sess[count], nil, 0, count);
1576+timeit_tag_dt_float("Before local setupsession", "Time for local setupsession");
15291577 DPRINT(DEXE, "reslocal: reservation: count=%d out of %d\n", count+1, g->size);
1578+stamp("Before local cloneproc");
15301579 proccreate(cloneproc, &g->sess[count], STACK);
1580+timeit_tag_dt_float("Before local cloneproc", "Time for local cloneproc");
15311581 }
15321582
15331583 /*
@@ -1538,15 +1588,19 @@ reslocal(Gang *g) · 4 unmodified lines
15381588 *
15391589 */
15401590
1591+stamp("Before local recvp");
15411592 for(count = 0; count < g->size; count++) {
15421593 char *myerr;
15431594 DPRINT(DEXE, "\twaiting on reservation: count=%d out of %d\n",
15441595 count+1, g->size);
1596+stamp("local recvp");
15451597 myerr = recvp(g->sess[count].chan);
1598+timeit_tag_dt_float("local recvp", "Time for single local recvp");
15461599 if(myerr != nil)
15471600 err = myerr;
15481601 /* MAYBE: retry here? for reliability ? */
15491602 }
1603+timeit_tag_dt_float("Before local recvp", "Time for local recvp total");
15501604
15511605 return err;
15521606 }
@@ -1582,6 +1636,7 @@ resgang(Gang *g) · 29 unmodified lines
15821636 remaining = size;
15831637 /* walk children tree, allocating cores and incrementing stats.njobs
15841638 counting sessions and keeping children per subsession in an array? */
1639+//stamp("Before walk");
15851640 for(current=mystats.next; current !=nil; current = current->next) {
15861641 int avail = current->ntask - current->njobs;
15871642 if(avail >= remaining) {
@@ -1596,7 +1651,11 @@ resgang(Gang *g) · 8 unmodified lines
15961651 if(njobs[scount] > 0) /* only increment when we've allocated a subnode */
15971652 scount++;
15981653 }
1599−
1654+//stamp("After walk");
1655+//timeit_settype(TIMIT_FLOAT);
1656+//timeit_tag_dt("Before walk", "After walk", "Time for walk");
1657+//timeit_settype(TIMIT_DEFAULT);
1658+
16001659 scount++; /* count instead of index now */
16011660
16021661 /* allocate subsessions */
@@ -1606,23 +1665,29 @@ resgang(Gang *g) · 3 unmodified lines
16061665 DPRINT(DGAN, "Gang opening up %d sessions\n", scount);
16071666
16081667 current = mystats.next;
1668+stamp("Before loop");
16091669 for(count = 0; count < scount; count++) {
1610− // FIXME: try moving checkmount to initstatus
1611− // checkmount(current->name);
1670+//stamp("Before checkmount");
1671+ checkmount(current->name);
1672+//timeit_dt_last_float("Time for checkmount");
16121673
16131674 if(njobs[count] == 0)
16141675 continue;
16151676 DPRINT(DGAN, "resgang: Session %d Target %s Njobs: %d From %s\n",
16161677 count, current->name, njobs[count], mysysname);
16171678
1679+//stamp("Before setupsess");
16181680 setupsess(g, &g->sess[count], current->name, njobs[count], count);
1619−
1681+//timeit_dt_last_float("Time for setupsess");
1682+
16201683 proccreate(cloneproc, &g->sess[count], STACK);
16211684 current = current->next;
16221685 }
1686+timeit_tag_dt_float("Before loop", "Time for loop");
16231687
16241688 DPRINT(DGAN, "waiting on %d sessions\n", scount);
16251689
1690+stamp("Before loop2");
16261691 for(count = 0; count < scount; count++) {
16271692 char *myerr;
16281693 DPRINT(DGAN, "\twaiting on reservation: count=%d out of %d\n", count+1, scount);
@@ -1636,6 +1701,7 @@ resgang(Gang *g) · 7 unmodified lines
16361701 g->status = GANG_BROKE;
16371702 }
16381703 }
1704+timeit_dt_last_float("Time for loop2");
16391705
16401706 return err;
16411707 }
@@ -1687,6 +1753,7 @@ cmdres(Req *r, int num) · 45 unmodified lines
16871753 respond(r, Ebadimode);
16881754 goto cleanuperror;
16891755 };
1756+stamp("Before mpipes");
16901757 if (mpipe(dest, "stdout") < 0) {
16911758 respond(r, Estdout);
16921759 goto cleanuperror;
@@ -1695,14 +1762,20 @@ cmdres(Req *r, int num) · 2 unmodified lines
16951762 respond(r, Estderr);
16961763 goto cleanuperror;
16971764 }
1765+timeit_dt_last_float("Time for mpipes");
16981766
16991767 g->size = num;
17001768
17011769 /* this assumes top down reservation model */
1702− if(mystats.nchild)
1770+ if(mystats.nchild){
1771+ stamp("Before resgang");
17031772 err = resgang(g);
1704− else
1773+timeit_tag_dt_float("Before resgang", "Time for RES gang");
1774+ }else{
1775+stamp("Before reslocal");
17051776 err = reslocal(g);
1777+timeit_tag_dt_float("Before reslocal", "Time for RES local");
1778+ }
17061779
17071780 if(err) {
17081781 DPRINT(DERR, "*ERROR*: problem establishing gang reservation: %s\n", err);
@@ -2159,6 +2232,9 @@ threadmain(int argc, char **argv) · 450 unmodified lines
21592232 proccreate(updatestatus, (void *)parent, STACK);
21602233 }
21612234
2235+ timeit_init();
2236+ //timeit_setsilent(1);
2237+
21622238 /* spawn off a io thread */
21632239 iochan = chancreate(sizeof(void *), 0);
21642240 clunkchan = chancreate(sizeof(void *), 0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t