Perf: changed route update pattern to be more like common protocols
This commit is contained in:
parent
e2630a494e
commit
dc042d87cb
2 changed files with 30 additions and 38 deletions
|
@ -85,12 +85,11 @@ random_net_ip4(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct perf_random_routes {
|
struct perf_random_routes {
|
||||||
|
struct rta *a;
|
||||||
net_addr net;
|
net_addr net;
|
||||||
rte *ep;
|
|
||||||
struct rta a;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint perf_random_routes_size = sizeof(struct perf_random_routes) + (RTA_MAX_SIZE - sizeof(struct rta));
|
//static const uint perf_random_routes_size = sizeof(struct perf_random_routes) + (RTA_MAX_SIZE - sizeof(struct rta));
|
||||||
|
|
||||||
static inline s64 timediff(struct timespec *begin, struct timespec *end)
|
static inline s64 timediff(struct timespec *begin, struct timespec *end)
|
||||||
{ return (end->tv_sec - begin->tv_sec) * (s64) 1000000000 + end->tv_nsec - begin->tv_nsec; }
|
{ return (end->tv_sec - begin->tv_sec) * (s64) 1000000000 + end->tv_nsec - begin->tv_nsec; }
|
||||||
|
@ -126,12 +125,10 @@ perf_loop(void *data)
|
||||||
struct perf_proto *p = data;
|
struct perf_proto *p = data;
|
||||||
|
|
||||||
const uint N = 1U << p->exp;
|
const uint N = 1U << p->exp;
|
||||||
const uint offset = perf_random_routes_size;
|
|
||||||
|
|
||||||
if (!p->run) {
|
if (!p->run) {
|
||||||
ASSERT(p->data == NULL);
|
ASSERT(p->data == NULL);
|
||||||
p->data = xmalloc(offset * N);
|
p->data = xmalloc(sizeof(struct perf_random_routes) * N);
|
||||||
bzero(p->data, offset * N);
|
|
||||||
p->stop = 1;
|
p->stop = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,49 +138,40 @@ perf_loop(void *data)
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts_begin);
|
clock_gettime(CLOCK_MONOTONIC, &ts_begin);
|
||||||
|
|
||||||
struct rta *a = NULL;
|
|
||||||
|
|
||||||
for (uint i=0; i<N; i++) {
|
for (uint i=0; i<N; i++) {
|
||||||
struct perf_random_routes *prr = p->data + offset * i;
|
*((net_addr_ip4 *) &(p->data[i].net)) = random_net_ip4();
|
||||||
*((net_addr_ip4 *) &prr->net) = random_net_ip4();
|
|
||||||
|
|
||||||
if (!p->attrs_per_rte || !(i % p->attrs_per_rte)) {
|
if (!p->attrs_per_rte || !(i % p->attrs_per_rte)) {
|
||||||
a = &prr->a;
|
struct rta a0 = {
|
||||||
bzero(a, RTA_MAX_SIZE);
|
.src = p->p.main_source,
|
||||||
|
.source = RTS_PERF,
|
||||||
|
.scope = SCOPE_UNIVERSE,
|
||||||
|
.dest = RTD_UNICAST,
|
||||||
|
.nh.iface = p->ifa->iface,
|
||||||
|
.nh.gw = gw,
|
||||||
|
.nh.weight = 1,
|
||||||
|
};
|
||||||
|
|
||||||
a->src = p->p.main_source;
|
p->data[i].a = rta_lookup(&a0);
|
||||||
a->source = RTS_PERF;
|
|
||||||
a->scope = SCOPE_UNIVERSE;
|
|
||||||
a->dest = RTD_UNICAST;
|
|
||||||
|
|
||||||
a->nh.iface = p->ifa->iface;
|
|
||||||
a->nh.gw = gw;
|
|
||||||
a->nh.weight = 1;
|
|
||||||
|
|
||||||
if (p->attrs_per_rte)
|
|
||||||
a = rta_lookup(a);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
ASSERT(a);
|
p->data[i].a = rta_clone(p->data[i-1].a);
|
||||||
|
|
||||||
prr->ep = rte_get_temp(a);
|
|
||||||
prr->ep->pflags = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts_generated);
|
clock_gettime(CLOCK_MONOTONIC, &ts_generated);
|
||||||
|
|
||||||
for (uint i=0; i<N; i++) {
|
for (uint i=0; i<N; i++) {
|
||||||
struct perf_random_routes *prr = p->data + offset * i;
|
rte *e = rte_get_temp(p->data[i].a);
|
||||||
rte_update(P, &prr->net, prr->ep);
|
e->pflags = 0;
|
||||||
|
|
||||||
|
rte_update(P, &(p->data[i].net), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts_update);
|
clock_gettime(CLOCK_MONOTONIC, &ts_update);
|
||||||
|
|
||||||
if (!p->keep)
|
if (!p->keep)
|
||||||
for (uint i=0; i<N; i++) {
|
for (uint i=0; i<N; i++)
|
||||||
struct perf_random_routes *prr = p->data + offset * i;
|
rte_update(P, &(p->data[i].net), NULL);
|
||||||
rte_update(P, &prr->net, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts_withdraw);
|
clock_gettime(CLOCK_MONOTONIC, &ts_withdraw);
|
||||||
|
|
||||||
|
@ -229,10 +217,10 @@ perf_feed_begin(struct channel *c, int initial UNUSED)
|
||||||
struct perf_proto *p = (struct perf_proto *) c->proto;
|
struct perf_proto *p = (struct perf_proto *) c->proto;
|
||||||
|
|
||||||
p->run++;
|
p->run++;
|
||||||
p->data = xmalloc(sizeof(struct timespec));
|
p->feed_begin = xmalloc(sizeof(struct timespec));
|
||||||
p->exp = 0;
|
p->exp = 0;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, p->data);
|
clock_gettime(CLOCK_MONOTONIC, p->feed_begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -242,10 +230,13 @@ perf_feed_end(struct channel *c)
|
||||||
struct timespec ts_end;
|
struct timespec ts_end;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts_end);
|
clock_gettime(CLOCK_MONOTONIC, &ts_end);
|
||||||
|
|
||||||
s64 feedtime = timediff(p->data, &ts_end);
|
s64 feedtime = timediff(p->feed_begin, &ts_end);
|
||||||
|
|
||||||
PLOG("feed n=%lu time=%lu", p->exp, feedtime);
|
PLOG("feed n=%lu time=%lu", p->exp, feedtime);
|
||||||
|
|
||||||
|
xfree(p->feed_begin);
|
||||||
|
p->feed_begin = NULL;
|
||||||
|
|
||||||
if (p->run < p->repeat)
|
if (p->run < p->repeat)
|
||||||
channel_request_feeding(c);
|
channel_request_feeding(c);
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,7 +29,8 @@ struct perf_config {
|
||||||
struct perf_proto {
|
struct perf_proto {
|
||||||
struct proto p;
|
struct proto p;
|
||||||
struct ifa *ifa;
|
struct ifa *ifa;
|
||||||
void *data;
|
struct perf_random_routes *data;
|
||||||
|
struct timespec *feed_begin;
|
||||||
event *loop;
|
event *loop;
|
||||||
btime threshold_min;
|
btime threshold_min;
|
||||||
btime threshold_max;
|
btime threshold_max;
|
||||||
|
|
Loading…
Reference in a new issue