-
Notifications
You must be signed in to change notification settings - Fork 7
/
sim.php
executable file
·98 lines (84 loc) · 2.6 KB
/
sim.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /usr/bin/env php
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2019 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// Trace-based simulation of Science United;
// predict project throughputs as a function of shares.
// - use as much of the actual code as possible (emulate)
// - but we can't modify the DB in the process.
// Also, for efficiency, read the DB only at the start
//
// Maintain the following in-memory structures:
// - set of users
// keyword prefs
// - set of hosts
// corresponding user
// list of processing resources
// project using each one
// - set of projects
// keywords
// app version descriptors (plaform, GPU type, is_vbox)
// accounting record
// - global accounting record
// - global allocation record
//
// The simulation works as follows:
// for each day
// simulate RPCs from each of the hosts (random times)
// estimate how much EC each attached project got
// update project accounting records
// select new projects
// simulate end-of-day accounting
// TODO
// model projects with bursty workloads,
// and measure the turnaround time of their bursts
// What we don't model
// in-progress jobs: they just add a buffer-sized phase delay
require_once("../inc/boinc_db.inc");
require_once("../inc/su_schedule.inc");
$users = array();
$hosts = null;
function init() {
global $users, $hosts;
$us = BoincUser::enum("");
foreach ($us as $u) {
$u->keywords = SUUserKeyword::enum("user_id=$u->id");
$users[$u->id] = $u;
}
echo "read users\n";
$hosts = BoincHost::enum("");
foreach ($hosts as $h) {
host_serialnum_to_gpus_vbox($h);
}
echo "read hosts\n";
}
function sim_rpc() {
}
function simulate_day() {
global $hosts;
foreach ($hosts as $h) {
sim_rpc($h);
}
}
function simulate($ndays) {
for ($i=0; $i<$ndays; $i++) {
simulate_day();
}
}
init();
//simulate(30);
?>