mirror of https://github.com/BOINC/boinc.git
- Added database table credit_multiplier and script to be run daily
(calculate_credit_multiplier) to determine what factor to multiply claimed credit by before insertion into the database. Changes to scheduler to implement have not yet been checked in. svn path=/trunk/boinc/; revision=15309
This commit is contained in:
parent
5583762116
commit
70baf36e93
|
@ -4450,3 +4450,16 @@ David May 28 2008
|
|||
html/user/
|
||||
forum_forum.php
|
||||
white.css
|
||||
|
||||
Eric May 28 2008
|
||||
- Added database table credit_multiplier and script to be run daily
|
||||
(calculate_credit_multiplier) to determine what factor to multiply claimed
|
||||
credit by before insertion into the database. Changes to scheduler to
|
||||
implement have not yet been checked in.
|
||||
|
||||
tools/
|
||||
Makefile.am
|
||||
calculate_credit_multiplier
|
||||
db/
|
||||
schema.sql
|
||||
|
||||
|
|
|
@ -581,3 +581,12 @@ create table notify (
|
|||
opaque integer not null
|
||||
-- some other ID, e.g. that of the thread, user or PM record
|
||||
);
|
||||
|
||||
-- credit multiplier. Used by the assimilator and autoadjust_credit script
|
||||
-- to automatically adjust granted credit.
|
||||
create table credit_multiplier (
|
||||
id serial primary key,
|
||||
time integer not null,
|
||||
multiplier double not null default 0;
|
||||
) engine=MyISAM;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ include $(top_srcdir)/Makefile.incl
|
|||
|
||||
bin_PROGRAMS = create_work sign_executable dir_hier_path dir_hier_move
|
||||
|
||||
EXTRA_DIST = make_project xadd update_versions dbcheck_files_exist upgrade makelog.sh cleanlogs.sh vote_monitor
|
||||
EXTRA_DIST = make_project xadd update_versions dbcheck_files_exist upgrade makelog.sh cleanlogs.sh vote_monitor calculate_credit_multiplier
|
||||
|
||||
LDADD = $(LIBSCHED) $(LIBBOINC) $(RSA_LIBS) $(MYSQL_LIBS)
|
||||
AM_CXXFLAGS = $(MYSQL_CFLAGS)
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
#! /bin/sh
|
||||
dbhost=`grep db_host ../config.xml | tr '[\<\>]' '[ ]' | head -1 | awk '{print $2}'`
|
||||
dbuser=`grep db_user ../config.xml | tr '[\<\>]' '[ ]' | head -1 | awk '{print $2}'`
|
||||
dbname=`grep db_name ../config.xml | tr '[\<\>]' '[ ]' | head -1 | awk '{print $2}'`
|
||||
MYSQL="mysql -D $dbname -h $dbhost -u $dbuser -N -B"
|
||||
|
||||
DECAY_TIME=30*86400
|
||||
|
||||
function median_query() {
|
||||
$MYSQL --execute="
|
||||
create temporary table medians (id int auto_increment primary key)
|
||||
select $1 from host
|
||||
where rpc_time>unix_timestamp(now())-($DECAY_TIME)
|
||||
and credit_per_cpu_sec>0
|
||||
order by $1;
|
||||
create temporary table ids
|
||||
select round(avg(id)-0.5) as id from medians;
|
||||
insert into ids select round(avg(id)+0.5) from medians;
|
||||
select avg($1) from medians where id in (
|
||||
select id from ids
|
||||
);
|
||||
drop table medians;
|
||||
drop table ids;"
|
||||
}
|
||||
|
||||
median_credit_per_cpu_sec=`median_query credit_per_cpu_sec`
|
||||
median_p_fpops=`median_query p_fpops`
|
||||
median_p_iops=`median_query p_iops`
|
||||
ratio=`$MYSQL --execute="select ($median_p_fpops+$median_p_iops)/($median_credit_per_cpu_sec)*5.787037037037e-13"`
|
||||
|
||||
nrows=`$MYSQL --execute="select count(id) from credit_multiplier"`
|
||||
if [ $nrows = 0 ] ; then
|
||||
$MYSQL --execute="insert into credit_multiplier values (0,unix_timestamp(now())-86400,1.0)"
|
||||
fi
|
||||
|
||||
last_value=`$MYSQL --execute="select multiplier from credit_multiplier where (unix_timestamp(now())-time)=(select min(unix_timestamp(now())-time) from credit_multiplier)"`
|
||||
last_time=`$MYSQL --execute="select unix_timestamp(now())-time from credit_multiplier where (unix_timestamp(now())-time)=(select min(unix_timestamp(now())-time) from credit_multiplier)"`
|
||||
|
||||
value=`$MYSQL --execute="select ($last_value*(($DECAY_TIME)-$last_time)+$ratio*$last_time)/($DECAY_TIME)"`
|
||||
|
||||
$MYSQL --execute="insert into credit_multiplier values (0,unix_timestamp(now()),$value);"
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue