.
// web interface to client simulator
//
// to use this, symlink to it from the html/user dir of a BOINC project,
// create an apache-writable dir called "scenarios" there,
// and symlink from html/inc to sim_util.inc
require_once("../inc/util.inc");
require_once("../inc/sim_util.inc");
function get_comments($dir) {
$d = "$dir/comments";
if (!is_dir($d)) return null;
$dd = opendir($d);
$x = "";
while (false !== ($f = readdir($dd))) {
if ($f == ".") continue;
if ($f == "..") continue;
if (strlen($x)) $x .= "
";
}
// show existing scenarios, "create scenario" button
//
function show_scenarios() {
page_head("The BOINC Client Emulator");
echo "
Welcome to the BOINC Client Emulator (BCE).
BCE emulates a BOINC client attached to one or more projects.
It predicts, in a few seconds,
what the BOINC client will do over a period of day or months.
This lets you predict how future versions of BOINC
will perform on your computers.
By reporting problem situations to BOINC developers,
you can help us fix bugs and improve performance.
Scenarios
The inputs to BCE, called scenarios,
describe a particular computer and the project to which it's attached.
A scenario consists of 4 files:
client_state.xml: describes the host and projects.
Any projects that don't currently have tasks are ignored.
global_prefs.xml and global_prefs_override.xml:
computing preferences (optional).
cc_config.xml: client configuration (optional).
You can use the files from a running BOINC client
to emulate that client.
You can modify these files, or create new ones, to study hypothetical scenarios
(e.g. hosts with a large number of CPUs,
hosts attached to a large number of projects,
projects with very short or long jobs, and so on).
See The
BCE documentation for details.
You create a scenario by uploading these files to the BOINC server.
Simulations
You can run simulations based on existing scenarios
(including scenarios created by other people).
The parameters of a simulation include
The duration and time resolution of the simulation.
Choices for various client policy alternatives, including:
Whether to use Recent Estimated Credit scheduling
(the proposed policy for the 6.14 client)
Whether to use Hysteresis-based work fetch
(the proposed policy for the 6.14 client)
The outputs of a simulation include
A 'time line' showing CPU and GPU usage.
The client's message log
graphs of scheduling-related data (debt, REC).
A summary of several figures of merit, including
idle fraction: the fraction of processing power that was unused
wasted fraction: the fraction of processing power
that was 'wasted' on jobs that missed their deadline
resource share violation: a measure [0..1] of the extent
to which resource shares were disobeyed.
monotony: a measure [0..1] of the extent to which
the client ran jobs of a single project for long periods
Comments and reports
When you examine the results of a simulation,
you may find places where the BOINC client
made bad scheduling or work-fetch decisions.
Or you find may places where the simulator doesn't
seem to be working correctly.
In such cases, please add a comment to the simulation,
indicating the nature of the problem
and the simulation time when it occurred.
Also, please post to the boinc_dev email list
if you have problems using BCE,
or if you have suggestions for new features.
";
show_button(
"sim_web.php?action=create_scenario_form",
"Create a scenario", "Create a new scenario"
);
echo "
Existing scenarios
";
start_table();
echo "
ID Click to see simulations
Who
When
# Simulations
Description
";
$d = opendir("scenarios");
while (false !== ($f = readdir($d))) {
if ($f === ".") continue;
if ($f === "..") continue;
show_scenario_summary($f);
}
echo "\n";
page_tail();
}
// show form for creating a scenario
//
function create_scenario_form() {
get_logged_in_user();
page_head("Create a scenario");
echo "
To create a scenario:
choose the input files,
enter a short description, and click OK
(items with * are required).
";
page_tail();
}
// create a subdir $dir/N for the first available N
//
function create_dir_seqno($dir) {
$i = -1;
$d = opendir($dir);
while (false !== ($f = readdir($d))) {
$j = -1;
$n = sscanf($f, "%d", $j);
if ($n == 1 && $j >= 0) {
if ($j > $i) {
$i = $j;
}
}
}
$i++;
$p = "$dir/$i";
mkdir($p);
return "$i";
}
// choose scenario name
// create dir, put files there
// create meta-data file
// redirect to show scenario
//
function create_scenario() {
$user = get_logged_in_user();
$csname = $_FILES['client_state']['tmp_name'];
if (!is_uploaded_file($csname)) {
error_page("You must specify a client_state.xml file.");
}
$desc = post_str("description", true);
if (!strlen($desc)) {
error_page("You must supply a description.");
}
$desc = strip_tags($desc);
$sname = create_dir_seqno("scenarios");
$d = "scenarios/$sname";
move_uploaded_file($csname, "$d/client_state.xml");
$gp = $_FILES['global_prefs']['tmp_name'];
if (is_uploaded_file($gp)) {
move_uploaded_file($gp, "$d/global_prefs.xml");
}
$gpo = $_FILES['global_prefs_override']['tmp_name'];
if (is_uploaded_file($gpo)) {
move_uploaded_file($gpo, "$d/global_prefs_override.xml");
}
$cc = $_FILES['cc_config']['tmp_name'];
if (is_uploaded_file($cc)) {
move_uploaded_file($cc, "$d/cc_config.xml");
}
file_put_contents("$d/userid", "$user->id");
file_put_contents("$d/description", $desc);
mkdir("$d/simulations");
header("Location: sim_web.php?action=show_scenario&name=$sname");
}
function show_simulation_summary($scen, $sim) {
$dir = "scenarios/$scen/simulations/$sim";
$userid = (int)file_get_contents("$dir/userid");
$user = BoincUser::lookup_id($userid);
$date = date_str(filemtime($dir));
echo "