function mem_model($n, $m) { $x = 0.0; $i = 0; $noNodes = 0; $noStreams = 0; global $sm_x; for ($i = 1; $i <= $n; $i++) { if ($i <= $m) { PDQ_Init(""); $noNodes = PDQ_CreateNode("CPU", CEN, FCFS); $noNodes = PDQ_CreateNode("DK1", CEN, FCFS); $noNodes = PDQ_CreateNode("DK2", CEN, FCFS); $noStreams = PDQ_CreateClosed("work", TERM, (double) $i, 0.0); PDQ_SetDemand("CPU", "work", 3.0); PDQ_SetDemand("DK1", "work", 4.0); PDQ_SetDemand("DK2", "work", 2.0); PDQ_Solve(EXACT); $x = PDQ_GetThruput(TERM, "work"); $sm_x[$i] = $x; } else { $sm_x[$i] = $x; /* last computed value */ } } }
function main() { global $job; /**************************** * Model specific variables * ****************************/ $noNodes = 0; $noStreams = 0; $pop = 0; $servers = 2; $s = 0; $w = HOMEPG; $work = array(0 => "stress", 1 => "homepg"); /* stress */ /* homepg */ $time = array(0 => 0.0044, 1 => 0.03); $slave = array(0 => "slave0", "slave1", "slave2", "slave3", "slave4", "slave5", "slave6", "slave7", "slave8", "slave9", "slave10", "slave11", "slave12", "slave13", "slave14", "slave15"); if (PREFORK) { printf("Pre-Fork Model under \"%s\" Load (m = %d)\n", $w == STRESS ? $work[STRESS] : $work[HOMEPG], $servers); } else { printf("Forking Model under \"%s\" Load \n", $w == STRESS ? $work[STRESS] : $work[HOMEPG]); } printf("N\tX\tR\n"); for ($pop = 1; $pop <= 10; $pop++) { PDQ_Init("HTTPd_Server"); $noStreams = PDQ_CreateClosed($work[$w], TERM, 1.0 * $pop, 0.0); $noNodes = PDQ_CreateNode("master", CEN, FCFS); if (PREFORK) { for ($s = 0; $s < $servers; $s++) { $noNodes = PDQ_CreateNode($slave[$s], CEN, FCFS); } PDQ_SetDemand("master", $work[$w], 0.0109); for ($s = 0; $s < $servers; $s++) { PDQ_SetDemand($slave[$s], $work[$w], $time[$w] / $servers); } } else { /* FORKING */ $noNodes = PDQ_CreateNode("forks", CEN, ISRV); PDQ_SetDemand("master", $work[$w], 0.0165); PDQ_SetDemand("forks", $work[$w], $time[$w]); } PDQ_Solve(EXACT); printf("%3.2f\t%3.4f\t%3.4f\n", getjob_pop(getjob_index($work[$w])), PDQ_GetThruput(TERM, $work[$w]), PDQ_GetResponse(TERM, $work[$w])); } }
function multiserver($m, $stime) { global $sm_x; $i = 0; $nodes = 0; $streams = 0; $x = 0.0; $work = "reqs"; $node = "bus"; for ($i = 1; $i <= CPUS; $i++) { if ($i <= $m) { PDQ_Init("multibus"); $streams = PDQ_CreateClosed($work, TERM, (double) $i, 0.0); $nodes = PDQ_CreateNode($node, CEN, ISRV); PDQ_SetDemand($node, $work, $stime); PDQ_Solve(EXACT); $x = PDQ_GetThruput(TERM, $work); $sm_x[$i] = $x; } else { $sm_x[$i] = $x; } } }
function main() { global $job; $model = "Middleware I"; $work = "eBiz-tx"; $node1 = "WebServer"; $node2 = "AppServer"; $node3 = "DBMServer"; $think = 0.0 * 0.001; // treated as free param // Added dummy servers for calibration $node4 = "DummySvr"; // User loads employed in WAS tool ... $noNodes = 0; $noStreams = 0; $users = 0; $u1pdq = array(); // double [MAXUSERS+1]; $u2pdq = array(); // double [MAXUSERS+1]; $u3pdq = array(); // double [MAXUSERS+1]; $u1err = array(); // double [MAXUSERS+1]; $u2err = array(); // double [MAXUSERS+1]; $u3err = array(); // double [MAXUSERS+1]; // Utilization data from the paper ... // In this example the following vectros contain zero value, so on line 106/107/108 can cause division by zero error!! $u1dat = array(0.0, 21.0, 41.0, 0.0, 74.0, 0.0, 0.0, 95.0, 0.0, 0.0, 96.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 96.0); // double [MAXUSERS+1] $u2dat = array(0.0, 8.0, 13.0, 0.0, 20.0, 0.0, 0.0, 23.0, 0.0, 0.0, 22.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 22.0); // double [MAXUSERS+1] $u3dat = array(0.0, 4.0, 5.0, 0.0, 5.0, 0.0, 0.0, 5.0, 0.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0); // double [MAXUSERS+1] // Output header ... printf("\n"); printf("(Tx: \"%s\" for \"%s\")\n\n", $work, $model); printf("Client delay Z=%5.2f mSec. (Assumed)\n\n", $think * 1000.0); printf("%3s\t%6s %6s %6s %6s %6s\n", " N ", " X ", " R ", "%Uws", "%Uas", "%Udb"); printf("%3s\t%6s %6s %6s %6s %6s\n", "---", "------", "------", "------", "------", "------"); for ($users = 1; $users <= MAXUSERS; $users++) { PDQ_Init($model); $noStreams = PDQ_CreateClosed($work, TERM, (double) $users, $think); $noNodes = PDQ_CreateNode($node1, CEN, FCFS); $noNodes = PDQ_CreateNode($node2, CEN, FCFS); $noNodes = PDQ_CreateNode($node3, CEN, FCFS); $noNodes = PDQ_CreateNode($node4, CEN, FCFS); //$noNodes = PDQ_CreateNode($node5, CEN, FCFS); //$noNodes = PDQ_CreateNode($node6, CEN, FCFS); // NOTE: timebase is seconds PDQ_SetDemand($node1, $work, 9.800000000000001 * 0.001); PDQ_SetDemand($node2, $work, 2.5 * 0.001); PDQ_SetDemand($node3, $work, 0.72 * 0.001); // dummy (network) nodes ... PDQ_SetDemand($node4, $work, 9.800000000000001 * 0.001); PDQ_Solve(EXACT); // set up for error analysis of utilzations $u1pdq[$users] = PDQ_GetUtilization($node1, $work, TERM) * 100; $u2pdq[$users] = PDQ_GetUtilization($node2, $work, TERM) * 100; $u3pdq[$users] = PDQ_GetUtilization($node3, $work, TERM) * 100; $u1err[$users] = 100 * ($u1pdq[$users] - $u1dat[$users]) / $u1dat[$users]; // cause division by zero error due to u1dat vector initialization $u2err[$users] = 100 * ($u2pdq[$users] - $u2dat[$users]) / $u2dat[$users]; // cause division by zero error due to u2dat vector initialization $u3err[$users] = 100 * ($u3pdq[$users] - $u3dat[$users]) / $u3dat[$users]; // cause division by zero error due to u3dat vector initialization printf("%3d\t%6.2f %6.2f %6.2f %6.2f %6.2f\n", $users, PDQ_GetThruput(TERM, $work), PDQ_GetResponse(TERM, $work) * 1000.0, $u1pdq[$users], $u2pdq[$users], $u3pdq[$users]); } // for user printf("\nError Analysis of Utilizations\n\n"); printf("%3s\t%12s %12s %12s\n", " ", " WS ", " AS ", " DB "); printf("%3s\t%12s %12s %12s\n", " ", "----------------------", "----------------------", "----------------------"); printf("%3s ", " N "); printf("%6s %6s %6s ", "%Udat", "%Updq", "%Uerr"); printf("%6s %6s %6s ", "%Udat", "%Updq", "%Uerr"); printf("%6s %6s %6s\n", "%Udat", "%Updq", "%Uerr"); printf("%3s ", "---"); printf("%6s %6s %6s ", "-----", "-----", "-----"); printf("%6s %6s %6s ", "-----", "-----", "-----"); printf("%6s %6s %6s\n", "-----", "-----", "-----"); for ($users = 1; $users <= MAXUSERS; $users++) { switch ($users) { case 1: case 2: case 4: case 7: case 10: case 20: printf("%3d\t%5.2f\t%5.2f\t%5.2f", $users, $u1dat[$users], $u1pdq[$users], $u1err[$users]); printf("\t%5.2f\t%5.2f\t%5.2f", $u2dat[$users], $u2pdq[$users], $u2err[$users]); printf("\t%5.2f\t%5.2f\t%5.2f\n", $u3dat[$users], $u3pdq[$users], $u3err[$users]); break; default: break; } } printf("\n"); // Uncomment the following line for a standard PDQ summary. PDQ_Report(); }
function PDQ_GetQueueLength($device, $work, $should_be_class) { global $PDQ_nodes, $PDQ_node; $q = 0.0; // double $x = 0.0; // double $c = 0; // int $k = 0; // int $c = PDQ_GetJobIndex($work); $x = PDQ_GetThruput($should_be_class, $work); for ($k = 0; $k < $PDQ_nodes; $k++) { if ($device == $PDQ_node[$k]->devname) { $q = $PDQ_node[$k]->resit[$c] * x; return $q; } } PDQ_ErrMsg(__FUNCTION__, "Unknown device " . $device); fprintf(STDERR, "%s:%d PDQ_GetQueueLength - Bad double return\n", __FILE__, __LINE__); return -1.0; }
function main() { global $nodes, $streams; $cname = ""; /* cache id */ $wname = ""; /* workload */ $i = 0; /* per CPU intruction stream intensity */ $Prhit = RD * HT; $Pwhit = WR * HT * (1 - WUMD) + WR * (1 - HT) * (1 - MD); $Prdop = RD * (1 - HT); $Pwbop = WR * (1 - HT) * MD; $Pwthr = WR; $Pinvl = WR * HT * WUMD; $Nrwht = 0.8075 * MAXCPU; $Nrdop = 0.08500000000000001 * MAXCPU; $Nwthr = 0.15 * MAXCPU; $Nwbop = 0.0003 * MAXCPU * 100; $Ninvl = 0.015 * MAXCPU; $Srdop = 20.0; $Swthr = 25.0; $Swbop = 20.0; $Wrwht = 0.0; $Wrdop = 0.0; $Wwthr = 0.0; $Wwbop = 0.0; $Winvl = 0.0; $Zrwht = ZX; $Zrdop = ZX; $Zwbop = ZX; $Zinvl = ZX; $Zwthr = ZX; $Xcpu = 0.0; $Pcpu = 0.0; $Ubrd = 0.0; $Ubwr = 0.0; $Ubin = 0.0; $Ucht = 0.0; $Ucrd = 0.0; $Ucwr = 0.0; $Ucin = 0.0; $model = "ABC Model"; PDQ_Init($model); PDQ_SetWUnit("Reqs"); PDQ_SetTUnit("Cycs"); /* create single bus queueing center */ $nodes = PDQ_CreateNode(BUS, CEN, FCFS); /* create per CPU cache queueing centers */ for ($i = 0; $i < MAXCPU; $i++) { namex($i, L2C, $cname); $nodes = PDQ_CreateNode($cname, CEN, FCFS); } /* create CPU nodes, workloads, and demands */ for ($i = 0; $i < intwt($Nrwht, $Wrwht); $i++) { namex($i, RWHT, $wname); $streams = PDQ_CreateClosed($wname, TERM, $Nrwht, $Zrwht); namex($i, L2C, $cname); PDQ_SetDemand($cname, $wname, 1.0); PDQ_SetDemand(BUS, $wname, 0.0); /* no bus activity */ } for ($i = 0; $i < intwt($Nrdop, $Wrdop); $i++) { namex($i, RDOP, $wname); $streams = PDQ_CreateClosed($wname, TERM, $Nrdop, $Zrdop); namex($i, L2C, $cname); PDQ_SetDemand($cname, $wname, GEN); /* generate bus request */ PDQ_SetDemand(BUS, $wname, $Srdop); /* req + async data return */ } if (WBACK) { for ($i = 0; $i < intwt($Nwbop, $Wwbop); $i++) { namex($i, WROP, $wname); $streams = PDQ_CreateClosed($wname, TERM, $Nwbop, $Zwbop); namex($i, L2C, $cname); PDQ_SetDemand($cname, $wname, GEN); PDQ_SetDemand(BUS, $wname, $Swbop); /* asych write to memory ? */ } } else { /* write-thru */ for ($i = 0; $i < intwt($Nwthr, $Wwthr); $i++) { namex($i, WROP, $wname); $streams = PDQ_CreateClosed($wname, TERM, $Nwthr, $Zwthr); namex($i, L2C, $cname); PDQ_SetDemand($cname, $wname, GEN); PDQ_SetDemand(BUS, $wname, $Swthr); } } if (WBACK) { for ($i = 0; $i < intwt($Ninvl, $Winvl); $i++) { namex($i, INVL, $wname); $streams = PDQ_CreateClosed($wname, TERM, $Ninvl, $Zinvl); namex($i, L2C, $cname); PDQ_SetDemand($cname, $wname, GEN); /* GEN + intervene */ PDQ_SetDemand(BUS, $wname, 1.0); } } PDQ_Solve(APPROX); /* bus utilizations */ for ($i = 0; $i < intwt($Nrdop, $Wrdop); $i++) { namex($i, RDOP, $wname); $Ubrd += PDQ_GetUtilization(BUS, $wname, TERM); } $Ubrd *= $Wrdop; if (WBACK) { for ($i = 0; $i < intwt($Nwbop, $Wwbop); $i++) { namex($i, WROP, $wname); $Ubwr += PDQ_GetUtilization(BUS, $wname, TERM); } $Ubwr *= $Wwbop; for ($i = 0; $i < intwt($Ninvl, $Winvl); $i++) { namex($i, INVL, $wname); $Ubin += PDQ_GetUtilization(BUS, $wname, TERM); } $Ubin *= $Winvl; } else { /* write-thru */ for ($i = 0; $i < intwt($Nwthr, $Wwthr); $i++) { namex($i, WROP, $wname); $Ubwr += PDQ_GetUtilization(BUS, $wname, TERM); } $Ubwr *= $Wwthr; } /* cache measures at CPU[0] only */ $i = 0; namex($i, L2C, $cname); namex($i, RWHT, $wname); $Xcpu = PDQ_GetThruput(TERM, $wname) * $Wrwht; $Pcpu += $Xcpu * $Zrwht; $Ucht = PDQ_GetUtilization($cname, $wname, TERM) * $Wrwht; namex($i, RDOP, $wname); $Xcpu = PDQ_GetThruput(TERM, $wname) * $Wrdop; $Pcpu += $Xcpu * $Zrdop; $Ucrd = PDQ_GetUtilization($cname, $wname, TERM) * $Wrdop; $Pcpu *= 1.88; if (WBACK) { namex($i, WROP, $wname); $Ucwr = PDQ_GetUtilization($cname, $wname, TERM) * $Wwbop; namex($i, INVL, $wname); $Ucin = PDQ_GetUtilization($cname, $wname, TERM) * $Winvl; } else { /* write-thru */ namex($i, WROP, $wname); $Ucwr = PDQ_GetUtilization($cname, $wname, TERM) * $Wwthr; } printf("\n**** %s Results ****\n", $model); printf("PDQ nodes: %d PDQ streams: %d\n", $nodes, $streams); printf("Memory Mode: %s\n", WBACK ? "WriteBack" : "WriteThru"); printf("Ncpu: %2d\n", MAXCPU); printf("Nrwht: %5.2f (N:%2d W:%5.2f)\n", $Nrwht, intwt($Nrwht, $Wrwht), $Wrwht); printf("Nrdop: %5.2f (N:%2d W:%5.2f)\n", $Nrdop, intwt($Nrdop, $Wrdop), $Wrdop); if (WBACK) { printf("Nwbop: %5.2f (N:%2d W:%5.2f)\n", $Nwbop, intwt($Nwbop, $Wwbop), $Wwbop); printf("Ninvl: %5.2f (N:%2d W:%5.2f)\n", $Ninvl, intwt($Ninvl, $Winvl), $Winvl); } else { printf("Nwthr: %5.2f (N:%2d W:%5.2f)\n", $Nwthr, intwt($Nwthr, $Wwthr), $Wwthr); } printf("\n"); printf("Hit Ratio: %5.2f %%\n", HT * 100.0); printf("Read Miss: %5.2f %%\n", RD * (1 - HT) * 100.0); printf("WriteMiss: %5.2f %%\n", WR * (1 - HT) * 100.0); printf("Ucpu: %5.2f %%\n", $Pcpu * 100.0 / MAXCPU); printf("Pcpu: %5.2f\n", $Pcpu); printf("\n"); printf("Ubus[reads]: %5.2f %%\n", $Ubrd * 100.0); printf("Ubus[write]: %5.2f %%\n", $Ubwr * 100.0); printf("Ubus[inval]: %5.2f %%\n", $Ubin * 100.0); printf("Ubus[total]: %5.2f %%\n", ($Ubrd + $Ubwr + $Ubin) * 100.0); printf("\n"); printf("Uca%d[hits]: %5.2f %%\n", $i, $Ucht * 100.0); printf("Uca%d[reads]: %5.2f %%\n", $i, $Ucrd * 100.0); printf("Uca%d[write]: %5.2f %%\n", $i, $Ucwr * 100.0); printf("Uca%d[inval]: %5.2f %%\n", $i, $Ucin * 100.0); printf("Uca%d[total]: %5.2f %%\n", $i, ($Ucht + $Ucrd + $Ucwr + $Ucin) * 100.0); }
function main() { global $job; $noNodes = 0; $noStreams = 0; $users = 0; $delta = 0; $model = "IIS Server"; $work = "http GET 20KB"; $node1 = "CPU"; $node2 = "DSK"; $node3 = "NET"; $node4 = "Dummy"; $think = 1.5 * 0.001; $u2demand = 0.1 * 0.001; $u1pdq = array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // array of double [11] $u2pdq = array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // array of double [11] $u3pdq = array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // array of double [11] $u1err = array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // array of double [11] $u2err = array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // array of double [11] $u3err = array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // array of double [11] // Utilization data from the paper ... $u1dat = array(0.0, 9.0, 14.0, 17.0, 21.0, 24.0, 26.0, 0.0, 0.0, 0.0, 26.0); // this can cause division by zero error $u2dat = array(0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 2.0); // this can cause division by zero error $u3dat = array(0.0, 26.0, 46.0, 61.0, 74.0, 86.0, 92.0, 0.0, 0.0, 0.0, 94.0); // this can cause division by zero error // Output main header ... printf("\n"); printf("(Tx: \"%s\" for \"%s\")\n\n", $work, $model); printf("Client delay Z=%5.2f mSec. (Assumed)\n\n", $think * 1000.0); printf("%3s\t%6s %6s %6s %6s %6s\n", " N ", " X ", " R ", "%Ucpu", "%Udsk", "%Unet"); printf("%3s\t%6s %6s %6s %6s %6s\n", "---", "------", "------", "------", "------", "------"); for ($users = 1; $users <= 10; $users++) { PDQ_Init($model); $noStreams = PDQ_CreateClosed($work, TERM, (double) $users, $think); $noNodes = PDQ_CreateNode($node1, CEN, FCFS); $noNodes = PDQ_CreateNode($node2, CEN, FCFS); $noNodes = PDQ_CreateNode($node3, CEN, FCFS); $noNodes = PDQ_CreateNode($node4, CEN, FCFS); // NOTE: timebase is seconds PDQ_SetDemand($node1, $work, 0.44 * 0.001); PDQ_SetDemand($node2, $work, $u2demand); /* make load-indept */ PDQ_SetDemand($node3, $work, 1.45 * 0.001); PDQ_SetDemand($node4, $work, 1.6 * 0.001); PDQ_Solve(EXACT); // set up for error analysis of utilzations $u1pdq[$users] = PDQ_GetUtilization($node1, $work, TERM) * 100; $u2pdq[$users] = PDQ_GetUtilization($node2, $work, TERM) * 100; $u3pdq[$users] = PDQ_GetUtilization($node3, $work, TERM) * 100; $u1err[$users] = 100 * ($u1pdq[$users] - $u1dat[$users]) / $u1dat[$users]; // raise division by zero error!! $u2err[$users] = 100 * ($u2pdq[$users] - $u2dat[$users]) / $u2dat[$users]; // raise division by zero error!! $u3err[$users] = 100 * ($u3pdq[$users] - $u3dat[$users]) / $u3dat[$users]; // raise division by zero error!! $u2demand = 0.015 / PDQ_GetThruput(TERM, $work); /* http GETs-per-second */ /* milliseconds */ printf("%3d\t%6.2f %6.2f %6.2f %6.2f %6.2f\n", $users, PDQ_GetThruput(TERM, $work), PDQ_GetResponse(TERM, $work) * 1000.0, $u1pdq[$users], $u2pdq[$users], $u3pdq[$users]); } printf("\nError Analysis of Utilizations\n\n"); printf("%3s\t%12s %12s %12s\n", " ", " CPU ", " DSK ", " NET "); printf("%3s\t%12s %12s %12s\n", " ", "----------------------", "----------------------", "----------------------"); printf("%3s ", " N "); printf("%6s %6s %6s ", "%Udat", "%Updq", "%Uerr"); printf("%6s %6s %6s ", "%Udat", "%Updq", "%Uerr"); printf("%6s %6s %6s\n", "%Udat", "%Updq", "%Uerr"); printf("%3s ", "---"); printf("%6s %6s %6s ", "-----", "-----", "-----"); printf("%6s %6s %6s ", "-----", "-----", "-----"); printf("%6s %6s %6s\n", "-----", "-----", "-----"); for ($users = 1; $users <= 10; $users++) { if ($users <= 6 || $users == 10) { printf("%3d\t%5.2f\t%5.2f\t%5.2f", $users, $u1dat[$users], $u1pdq[$users], $u1err[$users]); printf("\t%5.2f\t%5.2f\t%5.2f", $u2dat[$users], $u2pdq[$users], $u2err[$users]); printf("\t%5.2f\t%5.2f\t%5.2f\n", $u3dat[$users], $u3pdq[$users], $u3err[$users]); } } printf("\n"); }
function PDQ_GetQueueLength($device, $work, $should_be_class) { $p = "PDQ_GetQueueLength()"; // char * global $s1; //extern char[] global $nodes, $node; $q = 0.0; // double $x = 0.0; // double $c = 0; // int $k = 0; // int $c = getjob_index($work); $x = PDQ_GetThruput($should_be_class, $work); for ($k = 0; $k < $nodes; $k++) { if ($device == $node[$k]->devname) { $q = $node[$k]->resit[$c] * x; return $q; } } $s1 = sprintf("Unknown device %s", $device); errmsg($p, $s1); /*g_debug("PDQ_GetQueueLength - Bad double return");*/ fprintf(STDERR, "%s:%d PDQ_GetQueueLength - Bad double return\n", __FILE__, __LINE__); return -1.0; }