mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
MINOR: clock: split local and global date updates
Pollers that support busy polling spend a lot of time (and cause contention) updating the global date when they're looping over themselves while it serves no purpose: what's needed is only an update on the local date to know when to stop looping. This patch splits clock_pudate_date() into a pair of local and global update functions, so that pollers can be easily improved.
This commit is contained in:
parent
ae1e14d65b
commit
a700420671
@ -35,7 +35,8 @@ uint64_t now_cpu_time_thread(int thr);
|
|||||||
uint64_t now_mono_time(void);
|
uint64_t now_mono_time(void);
|
||||||
uint64_t now_cpu_time(void);
|
uint64_t now_cpu_time(void);
|
||||||
void clock_set_local_source(void);
|
void clock_set_local_source(void);
|
||||||
void clock_update_date(int max_wait, int interrupted);
|
void clock_update_local_date(int max_wait, int interrupted);
|
||||||
|
void clock_update_global_date();
|
||||||
void clock_init_process_date(void);
|
void clock_init_process_date(void);
|
||||||
void clock_init_thread_date(void);
|
void clock_init_thread_date(void);
|
||||||
int clock_setup_signal_timer(void *timer, int sig, int val);
|
int clock_setup_signal_timer(void *timer, int sig, int val);
|
||||||
@ -44,4 +45,10 @@ uint clock_report_idle(void);
|
|||||||
void clock_leaving_poll(int timeout, int interrupted);
|
void clock_leaving_poll(int timeout, int interrupted);
|
||||||
void clock_entering_poll(void);
|
void clock_entering_poll(void);
|
||||||
|
|
||||||
|
static inline void clock_update_date(int max_wait, int interrupted)
|
||||||
|
{
|
||||||
|
clock_update_local_date(max_wait, interrupted);
|
||||||
|
clock_update_global_date();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
23
src/clock.c
23
src/clock.c
@ -147,14 +147,10 @@ int clock_setup_signal_timer(void *tmr, int sig, int val)
|
|||||||
* values for the tv_sec and tv_usec parts. The offset is made of two signed
|
* values for the tv_sec and tv_usec parts. The offset is made of two signed
|
||||||
* ints so that the clock can be adjusted in the two directions.
|
* ints so that the clock can be adjusted in the two directions.
|
||||||
*/
|
*/
|
||||||
void clock_update_date(int max_wait, int interrupted)
|
void clock_update_local_date(int max_wait, int interrupted)
|
||||||
{
|
{
|
||||||
struct timeval min_deadline, max_deadline, tmp_now;
|
struct timeval min_deadline, max_deadline;
|
||||||
uint old_now_ms;
|
ullong ofs;
|
||||||
ullong old_now;
|
|
||||||
ullong new_now;
|
|
||||||
ullong ofs, ofs_new;
|
|
||||||
uint sec_ofs, usec_ofs;
|
|
||||||
|
|
||||||
gettimeofday(&date, NULL);
|
gettimeofday(&date, NULL);
|
||||||
|
|
||||||
@ -194,6 +190,19 @@ void clock_update_date(int max_wait, int interrupted)
|
|||||||
now.tv_sec += 1;
|
now.tv_sec += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
now_ms = __tv_to_ms(&now);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clock_update_global_date()
|
||||||
|
{
|
||||||
|
struct timeval tmp_now;
|
||||||
|
uint old_now_ms;
|
||||||
|
ullong old_now;
|
||||||
|
ullong new_now;
|
||||||
|
ullong ofs, ofs_new;
|
||||||
|
uint sec_ofs, usec_ofs;
|
||||||
|
|
||||||
|
ofs = HA_ATOMIC_LOAD(&now_offset);
|
||||||
|
|
||||||
/* now that we have bounded the local time, let's check if it's
|
/* now that we have bounded the local time, let's check if it's
|
||||||
* realistic regarding the global date, which only moves forward,
|
* realistic regarding the global date, which only moves forward,
|
||||||
|
Loading…
Reference in New Issue
Block a user