Skip to content

Commit

Permalink
Keep track of how much work is staged per-algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Nov 5, 2014
1 parent 1654709 commit 6c03a3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
23 changes: 16 additions & 7 deletions miner.c
Expand Up @@ -7131,6 +7131,18 @@ static void discard_work(struct work *work)
free_work(work);
}

static bool work_rollable(struct work *);

static
void unstage_work(struct work * const work)
{
HASH_DEL(staged_work, work);
--work_mining_algorithm(work)->staged;
if (work_rollable(work))
--staged_rollable;
staged_full = false;
}

static void wake_gws(void)
{
mutex_lock(stgd_lock);
Expand All @@ -7146,10 +7158,9 @@ static void discard_stale(void)
mutex_lock(stgd_lock);
HASH_ITER(hh, staged_work, work, tmp) {
if (stale_work(work, false)) {
HASH_DEL(staged_work, work);
unstage_work(work);
discard_work(work);
stale++;
staged_full = false;
}
}
pthread_cond_signal(&gws_cond);
Expand Down Expand Up @@ -7441,6 +7452,7 @@ static bool hash_push(struct work *work)
mutex_lock(stgd_lock);
if (work_rollable(work))
staged_rollable++;
++work_mining_algorithm(work)->staged;
if (likely(!getq->frozen)) {
HASH_ADD_INT(staged_work, id, work);
HASH_SORT(staged_work, tv_sort);
Expand Down Expand Up @@ -9199,10 +9211,9 @@ static void clear_pool_work(struct pool *pool)
mutex_lock(stgd_lock);
HASH_ITER(hh, staged_work, work, tmp) {
if (work->pool == pool) {
HASH_DEL(staged_work, work);
unstage_work(work);
free_work(work);
cleared++;
staged_full = false;
}
}
mutex_unlock(stgd_lock);
Expand Down Expand Up @@ -9822,9 +9833,7 @@ static struct work *hash_pop(struct cgpu_info * const proc)
goto retry;
}

HASH_DEL(staged_work, work);
if (work_rollable(work))
staged_rollable--;
unstage_work(work);

/* Signal the getwork scheduler to look for more work */
pthread_cond_signal(&gws_cond);
Expand Down
5 changes: 3 additions & 2 deletions miner.h
Expand Up @@ -1133,6 +1133,7 @@ struct mining_algorithm {
void (*hash_data_f)(void *digest, const void *data);

int goal_refs;
int staged;

struct mining_algorithm *next;
};
Expand Down Expand Up @@ -1595,11 +1596,11 @@ extern void work_set_simple_ntime_roll_limit(struct work *, int ntime_roll, cons
extern int work_ntime_range(struct work *, const struct timeval *tvp_earliest, const struct timeval *tvp_latest, int desired_roll);

static inline
const struct mining_algorithm *work_mining_algorithm(const struct work * const work)
struct mining_algorithm *work_mining_algorithm(const struct work * const work)
{
const struct pool * const pool = work->pool;
const struct mining_goal_info * const goal = pool->goal;
const struct mining_algorithm * const malgo = goal->malgo;
struct mining_algorithm * const malgo = goal->malgo;
return malgo;
}

Expand Down

0 comments on commit 6c03a3b

Please sign in to comment.