Averaging instead of max

This commit is contained in:
Quentin 2019-10-18 18:08:56 +02:00
parent 0e123fa55b
commit f21da52e8c
2 changed files with 42 additions and 14 deletions

View file

@ -92,7 +92,7 @@ ggplot(data=sqldf("select * from xa where run='out/bhTF0rd7MOI5SOPs-6'"), aes(x=
#geom_point(aes(shape=conf)) +
theme_classic()
xb <- read.csv("../res/tmp_light/t.csv")
xb <- read.csv("../res/tmp_light/v.csv")
xb$flag <- factor(xb$flag)
xb$link_id <- factor(xb$link_id)
xc <- sqldf("select *, 1.0 * latency / 1000.0 as lat from xb where vanilla = 1 and link_id = 7")
@ -102,6 +102,16 @@ ggplot(data=xc, aes(x=packet_id, y=lat, color=link_id:way)) +
#geom_point() +
theme_classic()
ggplot(data=sqldf("select
packet_id,way,latency,1.0 * MIN(latency) / 1000 as lat
from xb
group by packet_id,way"), aes(x=packet_id, y=lat, color=way)) +
coord_cartesian(ylim=c(100,600)) +
geom_line() +
#geom_point() +
theme_classic()
xd <- sqldf("
select
lat,

View file

@ -42,7 +42,8 @@ char* schedule_group_target_str[] = {
struct stat_entry {
uint8_t link_id;
int64_t max_ooo;
int64_t ooo;
int64_t meas_occ;
};
struct timing_entry {
@ -268,9 +269,9 @@ int algo_lightning_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* f
int compare_stat_entry_max(const void *a, const void *b) {
const struct stat_entry *sea = a, *seb = b;
if (sea->max_ooo == -1) return 1;
if (seb->max_ooo == -1) return -1;
return sea->max_ooo - seb->max_ooo;
if (sea->ooo == -1) return 1;
if (seb->ooo == -1) return -1;
return sea->ooo - seb->ooo;
}
void algo_lightning_update_stats (struct light_ctx *lightc, struct stat_entry *stats) {
@ -281,7 +282,8 @@ void algo_lightning_update_stats (struct light_ctx *lightc, struct stat_entry *s
// Init
for (int i = 0; i < lightc->total_links; i++) {
stats[i].link_id = i;
stats[i].max_ooo = -1;
stats[i].meas_occ = 0;
stats[i].ooo = -1;
}
// Compute local stats
@ -296,28 +298,44 @@ void algo_lightning_update_stats (struct light_ctx *lightc, struct stat_entry *s
case OOO_ONGOING:
timespec_diff(&now, &lightc->historic[i].detected_at, &temp_time);
delta = timespec_get_unit (&temp_time, MILISEC);
stats[l].ooo += delta;
stats[l].meas_occ += 1;
break;
case OOO_DONE:
timespec_diff(&lightc->historic[i].finished_at, &lightc->historic[i].detected_at, &temp_time);
delta = timespec_get_unit (&temp_time, MILISEC);
stats[l].ooo += delta;
stats[l].meas_occ += 1;
break;
}
if (lightc->explain) printf("(stats.compute) packet=%ld, link=%d, status=%s, delta=%ld\n", lightc->historic[i].pkt_id, l, ooo_state_str[lightc->historic[i].state], delta);
stats[l].link_id = l;
if (delta > stats[l].max_ooo) {
if (lightc->explain) printf("(stats.local) link=%d, delta=%ld\n", l, delta);
/*if (delta > stats[l].ooo) {
if (lightc->explain) printf("(stats.local) link=%d, delta=%ld\n", l, delta);
stats[l].max_ooo = delta;
}
stats[l].ooo = delta;
}*/
}
// Compute average
for (int i = 0; i < lightc->total_links; i++) {
if (stats[i].meas_occ <= 0) continue;
stats[i].ooo = stats[i].ooo / stats[i].meas_occ;
}
// Set my local stats + merge remote stats
for (int i = 0; i < lightc->total_links; i++) {
lightc->local_stats[i] = stats[i].max_ooo;
if (lightc->remote_stats[i] > stats[i].max_ooo) {
lightc->local_stats[i] = stats[i].ooo;
if (lightc->remote_stats[i] == -1) continue;
if (stats[i].ooo == -1) stats[i].ooo = lightc->remote_stats[i];
else stats[i].ooo = (lightc->remote_stats[i] + stats[i].ooo) / 2;
/*
if (lightc->remote_stats[i] > stats[i].ooo) {
if (lightc->explain) printf("(stats.remote) link=%d, delta=%d\n", i, lightc->remote_stats[i]);
stats[i].max_ooo = lightc->remote_stats[i];
}
stats[i].ooo = lightc->remote_stats[i];
}*/
}
// Sort
@ -414,7 +432,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
if (ctx->verbose > 1) {
printf("after sort: ");
for (int i = 0; i < lightc->total_links; i++) {
printf("%d (%ld), ", stats[i].link_id, stats[i].max_ooo);
printf("%d (%ld), ", stats[i].link_id, stats[i].ooo);
}
printf("\n");
}