mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-11 05:48:41 +00: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];
|
||||
|
||||
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);
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
/* Collect date and time information before calling poll(). This will be used
|
||||
* to count the run time of the past loop and the sleep time of the next poll.
|
||||
* It also makes use of the just updated before_poll timer to count the loop's
|
||||
* run time and feed the average loop time metric (in microseconds).
|
||||
/* Update avg_loop value for the current thread and possibly decide to enable
|
||||
* task-level profiling on the current thread based on its average run time.
|
||||
* The <run_time> argument is the number of microseconds elapsed since the
|
||||
* last time poll() returned.
|
||||
*/
|
||||
void activity_count_runtime()
|
||||
void activity_count_runtime(uint32_t run_time)
|
||||
{
|
||||
uint32_t run_time;
|
||||
uint32_t up, down;
|
||||
|
||||
/* 1 millisecond per loop on average over last 1024 iterations is
|
||||
@ -365,7 +364,6 @@ void activity_count_runtime()
|
||||
up = 1000;
|
||||
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);
|
||||
|
||||
/* 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_cpu_time;
|
||||
uint32_t run_time;
|
||||
int64_t stolen;
|
||||
|
||||
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_mono_time = now_mono_time();
|
||||
|
||||
@ -302,6 +305,9 @@ void clock_entering_poll(void)
|
||||
report_stolen_time(stolen);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the average runtime */
|
||||
activity_count_runtime(run_time);
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
||||
clock_entering_poll();
|
||||
activity_count_runtime();
|
||||
do {
|
||||
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);
|
||||
clock_entering_poll();
|
||||
activity_count_runtime();
|
||||
|
||||
do {
|
||||
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);
|
||||
fd = global.tune.maxpollevents;
|
||||
clock_entering_poll();
|
||||
activity_count_runtime();
|
||||
|
||||
do {
|
||||
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 */
|
||||
wait_time = wake ? 0 : compute_poll_timeout(exp);
|
||||
clock_entering_poll();
|
||||
activity_count_runtime();
|
||||
status = poll(poll_events, nbfd, wait_time);
|
||||
clock_update_date(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_usec = (delta_ms % 1000) * 1000;
|
||||
clock_entering_poll();
|
||||
activity_count_runtime();
|
||||
status = select(maxfd,
|
||||
readnotnull ? tmp_evts[DIR_RD] : NULL,
|
||||
writenotnull ? tmp_evts[DIR_WR] : NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user