-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[varnishstat] reset running averages #4274
base: master
Are you sure you want to change the base?
Conversation
I've been running benchmark tests these last few days, and I've been wishing to be able to reset the average calculations without having to restart `varnishncsa`, so here we go.
Please remove all mentions to |
Ah yes, of course |
Please also make it two commits, it's easier to back-port to any branch without the guaranteed conflict in the changelog. |
I accidentally submitted the previous comment, I meant to also ask for basic test coverage. |
sample_points(); | ||
sample_hitrate(); | ||
sample_points(reset_averages); | ||
sample_hitrate(reset_averages); | ||
reset_averages = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pass reset_averages
to the sample_*()
functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a quick 10 minutes job, and I assumed the key presses could come at any given time and wanted to avoid different counters from being handled differently, but I see the wgetch()
call now, I can indeed use the global variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's single-threaded, you are fine with globals :)
if (reset) { | ||
hitrate.hr_10.n = 0; | ||
hitrate.hr_100.n = 0; | ||
hitrate.hr_1000.n = 0; | ||
} | ||
update_ma(&hitrate.hr_10, ratio); | ||
update_ma(&hitrate.hr_100, ratio); | ||
update_ma(&hitrate.hr_1000, ratio); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you could use reset_averages
directly.
if (pt->t_last) | ||
if (reset) { | ||
pt->chg = 0; | ||
pt->ma_10.n = 0; | ||
pt->ma_100.n = 0; | ||
pt->ma_1000.n = 0; | ||
} else if (pt->t_last) | ||
pt->chg = ((int64_t)pt->cur - (int64_t)pt->last) / | ||
(pt->t_cur - pt->t_last); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with the block of code from my previous comment, shouldn't it look like this?
if (reset) { // or better: if (reset_averages)
pt->chg = 0;
pt->ma_10.n = 0;
pt->ma_100.n = 0;
pt->ma_1000.n = 0;
}
if (pt->t_last) {
pt->chg = ((int64_t)pt->cur - (int64_t)pt->last) /
(pt->t_cur - pt->t_last);
}
For the hit ratio you reset the 10/100/1000 averages and let them be updated in the same iteration. So for consistency you should give the counters a chance to be updated too.
I like phk's idea to use the |
I've been running benchmark tests these last few days, and I've been wishing to be able to reset the average calculations without having to restart
varnishncsa
, so here we go.