mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 05:41:26 +02:00
MINOR: activity: get the run_time from the clock updates
Instead of fiddling with before_poll and after_poll in activity_count_runtime(), the function is now called by clock_entering_poll() which passes it the number of microseconds spent working. This allows to remove all calls to activity_count_runtime() from the pollers.
This commit is contained in:
parent
f9d5e1079c
commit
20adfde9c8
@ -31,7 +31,7 @@ extern struct activity activity[MAX_THREADS];
|
|||||||
extern struct sched_activity sched_activity[256];
|
extern struct sched_activity sched_activity[256];
|
||||||
|
|
||||||
void report_stolen_time(uint64_t stolen);
|
void report_stolen_time(uint64_t stolen);
|
||||||
void activity_count_runtime();
|
void activity_count_runtime(uint32_t run_time);
|
||||||
struct sched_activity *sched_activity_entry(struct sched_activity *array, const void *func);
|
struct sched_activity *sched_activity_entry(struct sched_activity *array, const void *func);
|
||||||
|
|
||||||
#endif /* _HAPROXY_ACTIVITY_H */
|
#endif /* _HAPROXY_ACTIVITY_H */
|
||||||
|
@ -349,14 +349,13 @@ void report_stolen_time(uint64_t stolen)
|
|||||||
update_freq_ctr_period(&activity[tid].cpust_15s, 15000, stolen);
|
update_freq_ctr_period(&activity[tid].cpust_15s, 15000, stolen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Collect date and time information before calling poll(). This will be used
|
/* Update avg_loop value for the current thread and possibly decide to enable
|
||||||
* to count the run time of the past loop and the sleep time of the next poll.
|
* task-level profiling on the current thread based on its average run time.
|
||||||
* It also makes use of the just updated before_poll timer to count the loop's
|
* The <run_time> argument is the number of microseconds elapsed since the
|
||||||
* run time and feed the average loop time metric (in microseconds).
|
* last time poll() returned.
|
||||||
*/
|
*/
|
||||||
void activity_count_runtime()
|
void activity_count_runtime(uint32_t run_time)
|
||||||
{
|
{
|
||||||
uint32_t run_time;
|
|
||||||
uint32_t up, down;
|
uint32_t up, down;
|
||||||
|
|
||||||
/* 1 millisecond per loop on average over last 1024 iterations is
|
/* 1 millisecond per loop on average over last 1024 iterations is
|
||||||
@ -365,7 +364,6 @@ void activity_count_runtime()
|
|||||||
up = 1000;
|
up = 1000;
|
||||||
down = up * 99 / 100;
|
down = up * 99 / 100;
|
||||||
|
|
||||||
run_time = (before_poll.tv_sec - after_poll.tv_sec) * 1000000U + (before_poll.tv_usec - after_poll.tv_usec);
|
|
||||||
run_time = swrate_add(&activity[tid].avg_loop_us, TIME_STATS_SAMPLES, run_time);
|
run_time = swrate_add(&activity[tid].avg_loop_us, TIME_STATS_SAMPLES, run_time);
|
||||||
|
|
||||||
/* In automatic mode, reaching the "up" threshold on average switches
|
/* In automatic mode, reaching the "up" threshold on average switches
|
||||||
|
@ -283,10 +283,13 @@ void clock_entering_poll(void)
|
|||||||
{
|
{
|
||||||
uint64_t new_mono_time;
|
uint64_t new_mono_time;
|
||||||
uint64_t new_cpu_time;
|
uint64_t new_cpu_time;
|
||||||
|
uint32_t run_time;
|
||||||
int64_t stolen;
|
int64_t stolen;
|
||||||
|
|
||||||
gettimeofday(&before_poll, NULL);
|
gettimeofday(&before_poll, NULL);
|
||||||
|
|
||||||
|
run_time = (before_poll.tv_sec - after_poll.tv_sec) * 1000000U + (before_poll.tv_usec - after_poll.tv_usec);
|
||||||
|
|
||||||
new_cpu_time = now_cpu_time();
|
new_cpu_time = now_cpu_time();
|
||||||
new_mono_time = now_mono_time();
|
new_mono_time = now_mono_time();
|
||||||
|
|
||||||
@ -302,6 +305,9 @@ void clock_entering_poll(void)
|
|||||||
report_stolen_time(stolen);
|
report_stolen_time(stolen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* update the average runtime */
|
||||||
|
activity_count_runtime(run_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns the current date as returned by gettimeofday() in ISO+microsecond
|
/* returns the current date as returned by gettimeofday() in ISO+microsecond
|
||||||
|
@ -190,7 +190,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
|||||||
/* now let's wait for polled events */
|
/* now let's wait for polled events */
|
||||||
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
||||||
clock_entering_poll();
|
clock_entering_poll();
|
||||||
activity_count_runtime();
|
|
||||||
do {
|
do {
|
||||||
int timeout = (global.tune.options & GTUNE_BUSY_POLLING) ? 0 : wait_time;
|
int timeout = (global.tune.options & GTUNE_BUSY_POLLING) ? 0 : wait_time;
|
||||||
|
|
||||||
|
@ -160,7 +160,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
|||||||
*/
|
*/
|
||||||
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
||||||
clock_entering_poll();
|
clock_entering_poll();
|
||||||
activity_count_runtime();
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int timeout = (global.tune.options & GTUNE_BUSY_POLLING) ? 0 : wait_time;
|
int timeout = (global.tune.options & GTUNE_BUSY_POLLING) ? 0 : wait_time;
|
||||||
|
@ -147,7 +147,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
|||||||
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
||||||
fd = global.tune.maxpollevents;
|
fd = global.tune.maxpollevents;
|
||||||
clock_entering_poll();
|
clock_entering_poll();
|
||||||
activity_count_runtime();
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int timeout = (global.tune.options & GTUNE_BUSY_POLLING) ? 0 : wait_time;
|
int timeout = (global.tune.options & GTUNE_BUSY_POLLING) ? 0 : wait_time;
|
||||||
|
@ -203,7 +203,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
|||||||
/* now let's wait for events */
|
/* now let's wait for events */
|
||||||
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
||||||
clock_entering_poll();
|
clock_entering_poll();
|
||||||
activity_count_runtime();
|
|
||||||
status = poll(poll_events, nbfd, wait_time);
|
status = poll(poll_events, nbfd, wait_time);
|
||||||
clock_update_date(wait_time, status);
|
clock_update_date(wait_time, status);
|
||||||
clock_leaving_poll(wait_time, status);
|
clock_leaving_poll(wait_time, status);
|
||||||
|
@ -174,7 +174,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
|
|||||||
delta.tv_sec = (delta_ms / 1000);
|
delta.tv_sec = (delta_ms / 1000);
|
||||||
delta.tv_usec = (delta_ms % 1000) * 1000;
|
delta.tv_usec = (delta_ms % 1000) * 1000;
|
||||||
clock_entering_poll();
|
clock_entering_poll();
|
||||||
activity_count_runtime();
|
|
||||||
status = select(maxfd,
|
status = select(maxfd,
|
||||||
readnotnull ? tmp_evts[DIR_RD] : NULL,
|
readnotnull ? tmp_evts[DIR_RD] : NULL,
|
||||||
writenotnull ? tmp_evts[DIR_WR] : NULL,
|
writenotnull ? tmp_evts[DIR_WR] : NULL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user