File: submit_init_priority.php

package info (click to toggle)
boinc 7.14.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,132 kB
  • sloc: cpp: 163,589; php: 113,173; ansic: 49,284; pascal: 35,620; xml: 17,864; java: 13,521; python: 6,551; sh: 4,082; perl: 1,843; makefile: 1,796; objc: 1,543; sql: 959; csh: 126; lisp: 47
file content (88 lines) | stat: -rwxr-xr-x 2,806 bytes parent folder | download | duplicates (12)
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
#! /usr/bin/env php
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2012 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/>.

// initialize
//   user_submit.logical start_time
//   batch.logical_start_time
//   batch.logical_end_time
//   result.priority
// based on existing batches

require_once("../inc/boinc_db.inc");
require_once("../inc/submit_db.inc");

function process_batch($b) {
    $app = BoincApp::lookup_id($b->app_id);
    if (!$app) {
        echo "no app for batch $b->id\n";
        return;
    }
    if ($b->fraction_done>0 && $b->credit_canonical>0) {
        $credit_total = $b->credit_canonical/$b->fraction_done;
        $fpops_total = $credit_total*(86400e9/200);
    } else {
        $db = BoincDb::get();
        $fpops_total = $db->sum(
            "workunit", "rsc_fpops_est*target_nresults", "where batch=$b->id"
        );
    }
    echo "batch $b->id fpops_total $fpops_total\n";
    if ($fpops_total == 0) {
        return;
    }

    // adjust the user's logical start time
    //
    $user = BoincUser::lookup_id($b->user_id);
    if (!$user) die("no user $b->user_id\n");
    $us = BoincUserSubmit::lookup_userid("$user->id");
    if (!$us) die("no user submit record\n");
    $lst = $us->logical_start_time;
    $cmd = "cd ../../bin; ./adjust_user_priority --user $user->id --flops $fpops_total --app $app->name";
    system($cmd);
    $us = BoincUserSubmit::lookup_userid("$user->id");
    $let = $us->logical_start_time;
    $let = (int)$let;

    // set the priority of workunits and results in this batch
    // to the user's new logical start time
    //
    $clause = "priority=$let where batch=$b->id";
    BoincResult::update_aux($clause);
    BoincWorkunit::update_aux($clause);
}

function scan_batches() {
    $batches = BoincBatch::enum("", "order by id");
    foreach ($batches as $b) {
        process_batch($b);
    }
}

function reset_all() {
    BoincUserSubmit::update_aux("logical_start_time=0");
    BoincBatch::update_aux("logical_start_time=0, logical_end_time=0");
    BoincWorkunit::update_aux("priority=0");
    BoincResult::update_aux("priority=0");
}

scan_batches();
//reset_all();

?>