[Pvfs2-cvs] commit by pw in pvfs2/src/io/bmi: bmi.c
CVS commit program
cvs at parl.clemson.edu
Thu Dec 7 16:47:46 EST 2006
Update of /projects/cvsroot/pvfs2/src/io/bmi
In directory parlweb1:/tmp/cvs-serv3941/src/io/bmi
Modified Files:
bmi.c
Log Message:
* ib: cache explict BMI_memalloc registrations; huge latency improvement
* bmi: avoid gettimeofday() to determine poll vs block for multi-method
scenario
* ib: rely on bmi to make poll vs block decision
* ib: only check for new connections and async events during blocking periods
Index: bmi.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi.c,v
diff -u -p -p -u -r1.76 -r1.77
--- bmi.c 5 Dec 2006 22:00:11 -0000 1.76
+++ bmi.c 7 Dec 2006 21:47:46 -0000 1.77
@@ -85,10 +85,12 @@ static gen_mutex_t active_method_count_m
static struct bmi_method_ops **active_method_table = NULL;
static struct {
- struct timeval active;
- struct timeval polled;
+ int iters_polled; /* how many iterations since this method was polled */
+ int iters_active; /* how many iterations since this method had action */
int plan;
} *method_usage = NULL;
+static const int usage_iters_starvation = 100000;
+static const int usage_iters_active = 10000;
static int activate_method(const char *name, const char *listen_addr,
int flags);
@@ -777,43 +779,47 @@ int BMI_testsome(int incount,
static void
construct_poll_plan(int nmeth, int *idle_time_ms)
{
- struct timeval now, delta;
int i, numplan;
- gettimeofday(&now, 0);
numplan = 0;
for (i=0; i<nmeth; i++) {
+ ++method_usage[i].iters_polled;
+ ++method_usage[i].iters_active;
method_usage[i].plan = 0;
- timersub(&now, &method_usage[i].polled, &delta);
- if (delta.tv_sec >= 1) {
- method_usage[i].plan = 1; /* >= 1s starving */
- method_usage[i].polled = now;
+ if (method_usage[i].iters_active <= usage_iters_active) {
+ /* recently busy, poll */
+ if (0) gossip_debug(GOSSIP_BMI_DEBUG_CONTROL,
+ "%s: polling active meth %d: %d / %d\n", __func__, i,
+ method_usage[i].iters_active, usage_iters_active);
+ method_usage[i].plan = 1;
+ ++numplan;
+ *idle_time_ms = 0; /* busy polling */
+ } else if (method_usage[i].iters_polled >= usage_iters_starvation) {
+ /* starving, time to poke this one */
+ if (0) gossip_debug(GOSSIP_BMI_DEBUG_CONTROL,
+ "%s: polling starving meth %d: %d / %d\n", __func__, i,
+ method_usage[i].iters_polled, usage_iters_starvation);
+ method_usage[i].plan = 1;
++numplan;
- } else {
- timersub(&now, &method_usage[i].active, &delta);
- if (delta.tv_sec == 0) {
- method_usage[i].plan = 1; /* < 1s busy, prefer poll */
- method_usage[i].polled = now;
- ++numplan;
- }
}
}
/* if nothing is starving or busy, poll everybody */
if (numplan == 0) {
- for (i=0; i<nmeth; i++) {
+ for (i=0; i<nmeth; i++)
method_usage[i].plan = 1;
- method_usage[i].polled = now;
- }
numplan = nmeth;
- }
- /* spread idle time evenly */
- if (*idle_time_ms)
- {
- *idle_time_ms /= numplan;
- if (!*idle_time_ms)
- *idle_time_ms = 1;
+ /* spread idle time evenly */
+ if (*idle_time_ms) {
+ *idle_time_ms /= numplan;
+ if (*idle_time_ms == 0)
+ *idle_time_ms = 1;
+ }
+ /* note that BMI_testunexpected is always called with idle_time 0 */
+ if (0) gossip_debug(GOSSIP_BMI_DEBUG_CONTROL,
+ "%s: polling all %d methods, idle %d ms\n", __func__,
+ numplan, *idle_time_ms);
}
}
@@ -860,8 +866,9 @@ int BMI_testunexpected(int incount,
}
position += tmp_outcount;
(*outcount) += tmp_outcount;
- if (tmp_outcount)
- gettimeofday(&method_usage[i].active, 0);
+ method_usage[i].iters_polled = 0;
+ if (ret)
+ method_usage[i].iters_active = 0;
}
i++;
}
@@ -958,8 +965,9 @@ int BMI_testcontext(int incount,
}
position += tmp_outcount;
(*outcount) += tmp_outcount;
- if (tmp_outcount)
- gettimeofday(&method_usage[i].active, 0);
+ method_usage[i].iters_polled = 0;
+ if (ret)
+ method_usage[i].iters_active = 0;
}
i++;
}
More information about the Pvfs2-cvs
mailing list