From 6e6029de999d93683f7830f71dfb047722a2d037 Mon Sep 17 00:00:00 2001 From: Paul Sheppard Date: Tue, 3 Jul 2012 10:22:11 -0700 Subject: [PATCH 1/2] Timing tweaks Added long and short timeouts, short for detecting throttling, long to give up totally. Reset sleep time when device re-initialised Still check results after timeout Back up a larger time if result on first poll. --- driver-bitforce.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/driver-bitforce.c b/driver-bitforce.c index cf2d6ca0..5d89028f 100644 --- a/driver-bitforce.c +++ b/driver-bitforce.c @@ -21,7 +21,8 @@ #include "miner.h" #define BITFORCE_SLEEP_MS 3000 -#define BITFORCE_TIMEOUT_MS 10000 +#define BITFORCE_TIMEOUT_MS 7000 +#define BITFORCE_LONG_TIMEOUT_MS 15000 #define BITFORCE_CHECK_INTERVAL_MS 10 #define WORK_CHECK_INTERVAL_MS 50 #define MAX_START_DELAY_US 100000 @@ -196,6 +197,7 @@ void bitforce_init(struct cgpu_info *bitforce) } bitforce->device_fd = fdDev; + bitforce->sleep_ms = BITFORCE_SLEEP_MS; mutex_unlock(&bitforce->device_mutex); } @@ -301,7 +303,7 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work) if (!fdDev) return 0; - while (bitforce->wait_ms < BITFORCE_TIMEOUT_MS) { + while (bitforce->wait_ms < BITFORCE_LONG_TIMEOUT_MS) { if (unlikely(work_restart[thr->id].restart)) return 1; mutex_lock(&bitforce->device_mutex); @@ -317,20 +319,21 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work) } if (bitforce->wait_ms >= BITFORCE_TIMEOUT_MS) { - applog(LOG_ERR, "BFL%i: took longer than 10s", bitforce->device_id); + applog(LOG_ERR, "BFL%i: took longer than %dms", bitforce->device_id, BITFORCE_TIMEOUT_MS); bitforce->device_last_not_well = time(NULL); bitforce->device_not_well_reason = REASON_DEV_OVER_HEAT; bitforce->dev_over_heat_count++; - return 1; + if (!pdevbuf[0]) /* Only return if we got nothing after timeout - there still may be results */ + return 1; } else if (pdevbuf[0] == 'N') {/* Hashing complete (NONCE-FOUND or NO-NONCE) */ /* Simple timing adjustment */ delay_time_ms = bitforce->sleep_ms; if (bitforce->wait_ms > (bitforce->sleep_ms + BITFORCE_CHECK_INTERVAL_MS)) bitforce->sleep_ms += (unsigned int) ((double) (bitforce->wait_ms - bitforce->sleep_ms) / 1.6); else if (bitforce->wait_ms == bitforce->sleep_ms) - bitforce->sleep_ms -= BITFORCE_CHECK_INTERVAL_MS; + bitforce->sleep_ms -= WORK_CHECK_INTERVAL_MS; if (delay_time_ms != bitforce->sleep_ms) - applog(LOG_DEBUG, "BFL%i: Wait time changed to: %d. Waited: %d", bitforce->device_id, bitforce->sleep_ms, bitforce->wait_ms); + applog(LOG_DEBUG, "BFL%i: Wait time changed to: %d", bitforce->device_id, bitforce->sleep_ms, bitforce->wait_ms); } applog(LOG_DEBUG, "BFL%i: waited %dms until %s", bitforce->device_id, bitforce->wait_ms, pdevbuf); From c4870676c45277adc926a889f208b3b80bb49f64 Mon Sep 17 00:00:00 2001 From: Paul Sheppard Date: Tue, 3 Jul 2012 10:40:02 -0700 Subject: [PATCH 2/2] Add api stats (sleep time) --- driver-bitforce.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/driver-bitforce.c b/driver-bitforce.c index 5d89028f..27494c46 100644 --- a/driver-bitforce.c +++ b/driver-bitforce.c @@ -442,10 +442,24 @@ static bool bitforce_thread_init(struct thr_info *thr) return true; } +static struct api_data *bitforce_api_stats(struct cgpu_info *cgpu) +{ + struct api_data *root = NULL; + + // Warning, access to these is not locked - but we don't really + // care since hashing performance is way more important than + // locking access to displaying API debug 'stats' + // If locking becomes an issue for any of them, use copy_data=true also + root = api_add_int(root, "Sleep Time", &(cgpu->sleep_ms), false); + + return root; +} + struct device_api bitforce_api = { .dname = "bitforce", .name = "BFL", .api_detect = bitforce_detect, + .get_api_stats = bitforce_api_stats, .reinit_device = bitforce_init, .get_statline_before = get_bitforce_statline_before, .get_stats = bitforce_get_stats,