| PGL: Calls |
|---|
| Web Polygraph |
PGL supports these function and procedure calls:
| Function | Procedure |
|---|---|
Count function returns the number of items in the array arr.
One possible application is adjusting individual Robot request rates to match total request rate requirement.
rate total_req_rate = 2000/sec; Robot R; addr[] robot_hosts; // hosts to run robots on ... R.req_rate = total_req_rate / count(robot_hosts); place(R, robot_hosts);
The float function attempts to convert the value of obj into a floating point number. The type of obj can be int or any other type that can be converted to float.
See also: int().
The int function attempts to convert the value of obj into an integer number. The type of obj can be float or any other type that can be converted to int.
int n2 = int(3.5/2) // OK; n2 is equal to 1 int n1 = 3.5/2; // Error: type mismatchSee also: float().
Note: The place() function is not supported since Polygraph version 2.2.1. Use Agent's hosts field to bind robots and servers to network addresses (i.e., place agents on the specified hosts).
The place() function is used to assign agents to hosts. For each host h in the hosts array, place() creates a copy of agent with the host field set to h. The newly created agents are accumulated and returned as a result.
Server[] servers = place(S, srv_ips); Robot[] robots = place(R, rbt_ips); use(servers, robots);Note that the function knows whether is is dealing with robots or servers and creates/returns appropriate agents.
The undef() function returns an ``undefined'' value that is compatible with any type. The only useful application of this function is to reset the value of some field to its ``default''.
// import useful objects, including myRobot #include "my_objects.pg" // tell Polygraph to use default value for nagle option // when myRobot is launched myRobot.socket.nagle = undef();Note that the value of myRobot.socket.nagle in the example above becomes ``undefined'' and not some default value (true or false). The default is substituted after the configuration file is interpreted. That is why the function is called undef() and not default().
myServer.accept_lmt = -1; myServer.accept_lmt = undef(); // this is an error because myServer.accept_lmt is undefined: otherServer.accept_lmt = myServer.accept_lmt + 10;
Schedule is for phases as use() is for agents. Schedule iterates through the argument list and appends each phase to a global ``schedule''. Polyclt and polysrv will follow that schedule and will stop execution when all phases are completed.
#include "phases.pg" // import some useful phases Phase phMeas = { ... }; schedule(phWait, phMeas, phCool); // build a scheduleIf you call schedule() with an array instead of an individual phase, the array gets interpolated as if all its items were explicitly listed as actual parameters.
The schedule() procedure can be called more than once.
See also: use().
Use iterates through the argument list and marks each agent or pipe as being ``in use''. The polyclt, polysrv, and piper tools will ignore objects without the ``in use'' mark.
Server S = { .... }; Server S2 = { .... }; Robot R = { ... }; NetPipe pipe; use(S, R); use(pipe); // Server S2 will be ignoredIf you call use() with an array instead of an individual objects, the array gets interpolated as if all its items were explicitly listed as actual parameters.
Server[] servers = place(S, srv_ips); Robot[] robots = place(R, rbt_ips); use(servers, robots);The use() procedure allows you to create a library of robots, servers, and pipes but use only some subset of those objects.
The use() procedure can be called more than once.
Use working_set_length() call to limit the size of URL space (a.k.a. ``working set'' size). Polygraph constantly introduces new objects into the working set to simulate cachable misses. By default, the working set will grow indefinitely. In other words, more and more URLs will have a non-zero probability of being re-visited. This unlimited growth may eventually decrease memory hit ratio and even disk hit ratio (both due to finite cache sizes).
It is often convenient and desirable to limit the size of the working set. We specify that limit in terms of time (rather than number of objects or their total size) because that makes the limit independent from cache capacity or request rate. In other words, when two very different caches are subjected to the same time-based limit, the workload is ``fair''.
The working_set_length() call essentially specifies for how long a cache needs to store fill stream to achieve optimal hit ratio during the entire experiment. If a cache cannot hold all traffic generated during working_set_length time, then it is almost guaranteed to have sub-optimal hit ratio later, because some of the re-visited objects will not be in the cache.
time len = 4hour; working_set_length(len);Specifying working_set_length larger than experiment duration does not have any effect (the set will grow during the entire run then). One can think of the first working_set_length minutes of the experiment as of a ``warm-up'' phase. Experiment enters its ``steady state'' only after the working set size is frozen.
See also: schedule(), PopModel.
$Id: calls.sml,v 1.3 1999/11/09 21:28:44 rousskov Exp rousskov $