Browse Source

Bias early shares based on a simpler exponential function based on time since first share when calculating dsps

master
Con Kolivas 11 years ago
parent
commit
9c30d46b08
  1. 18
      src/stratifier.c

18
src/stratifier.c

@ -170,9 +170,9 @@ struct stratum_instance {
int old_diff; /* Previous diff */ int old_diff; /* Previous diff */
int diff_change_job_id; /* Last job_id we changed diff */ int diff_change_job_id; /* Last job_id we changed diff */
double dsps5; /* Diff shares per second, 5 minute rolling average */ double dsps5; /* Diff shares per second, 5 minute rolling average */
double bias; /* Bias for earlier shares */
tv_t ldc; /* Last diff change */ tv_t ldc; /* Last diff change */
int ssdc; /* Shares since diff change */ int ssdc; /* Shares since diff change */
tv_t first_share;
tv_t last_share; tv_t last_share;
int absolute_shares; int absolute_shares;
int diff_shares; int diff_shares;
@ -819,7 +819,7 @@ static void stratum_send_diff(stratum_instance_t *client)
static void add_submit(stratum_instance_t *client, int diff, bool valid) static void add_submit(stratum_instance_t *client, int diff, bool valid)
{ {
double tdiff, dsps, drr, network_diff; double tdiff, bdiff, dsps, drr, network_diff, bias;
int next_blockid, optimal; int next_blockid, optimal;
tv_t now_t; tv_t now_t;
@ -828,7 +828,8 @@ static void add_submit(stratum_instance_t *client, int diff, bool valid)
copy_tv(&client->last_share, &now_t); copy_tv(&client->last_share, &now_t);
client->ssdc++; client->ssdc++;
decay_time(&client->dsps5, diff, tdiff, 300); decay_time(&client->dsps5, diff, tdiff, 300);
decay_time(&client->bias, 0, tdiff, 300); bdiff = tvdiff(&now_t, &client->first_share);
bias = 1.0 - 1.0 / exp(bdiff / 300.0);
tdiff = tvdiff(&now_t, &client->ldc); tdiff = tvdiff(&now_t, &client->ldc);
if (valid) { if (valid) {
@ -847,8 +848,9 @@ static void add_submit(stratum_instance_t *client, int diff, bool valid)
return; return;
/* Diff rate ratio */ /* Diff rate ratio */
dsps = client->dsps5 * exp(client->bias); dsps = client->dsps5 / bias;
drr = dsps / (double)client->diff; drr = dsps / (double)client->diff;
/* Optimal rate product is 0.3, allow some hysteresis. */ /* Optimal rate product is 0.3, allow some hysteresis. */
if (drr > 0.2 && drr < 0.4) { if (drr > 0.2 && drr < 0.4) {
/* FIXME For now show the hashrate every ~1m when the diff is /* FIXME For now show the hashrate every ~1m when the diff is
@ -884,8 +886,8 @@ static void add_submit(stratum_instance_t *client, int diff, bool valid)
client->ssdc = 0; client->ssdc = 0;
LOGINFO("Client %d dsps %.1f drr %.2f adjust diff from %d to: %d ", client->id, LOGINFO("Client %d biased dsps %.2f dsps %.2f drr %.2f adjust diff from %d to: %d ",
client->dsps5, drr, client->diff, optimal); client->id, dsps, client->dsps5, drr, client->diff, optimal);
copy_tv(&client->ldc, &now_t); copy_tv(&client->ldc, &now_t);
client->diff_change_job_id = next_blockid; client->diff_change_job_id = next_blockid;
@ -904,8 +906,8 @@ static void add_submit_success(stratum_instance_t *client, int job_id, int wb_id
FILE *fp; FILE *fp;
int len; int len;
if (!client->absolute_shares++) if (unlikely(!client->absolute_shares++))
client->bias = 3; tv_time(&client->first_share);
client->diff_shares += diff; client->diff_shares += diff;
add_submit(client, diff, true); add_submit(client, diff, true);
len = strlen(client->workername) + 10; len = strlen(client->workername) + 10;

Loading…
Cancel
Save