Re: gettimeofday is at the end of its usefulness?

Поиск
Список
Период
Сортировка
От Ants Aasma
Тема Re: gettimeofday is at the end of its usefulness?
Дата
Msg-id CA+CSw_s_iTH_nw5XANEQARYuC3MFTqJ9eQZkux_2AocsM6xNLQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: gettimeofday is at the end of its usefulness?  (Greg Stark <stark@mit.edu>)
Список pgsql-hackers
On Wed, May 14, 2014 at 6:34 AM, Greg Stark <stark@mit.edu> wrote:
> I always assumed the kernel used rdtsc to implement some of the high
> performance timers. It can save the current time in a mapped page when
> it schedules a process and then in the vdso syscall (ie in user-space)
> it can use rdtsc to calculate the offset needed to adjust that
> timestamp to the current time. This seems consistent with your
> calculations that showed the 40ns overhead with +/- 10ns precision.

Both gettimeofday and clock_gettime do exactly that. [1]
clock_gettime(CLOCK_MONOTONIC) is the mode of operation we would want
to use here.

> I actually think it would be more interesting if we could measure the
> overhead and adjust for it. I don't think people are really concerned
> with how long EXPLAIN ANALYZE takes to run if they could get accurate
> numbers out of it.

Measuring would also be a good idea so we can automatically turn on
performance counters like IO timing when we know it's not obscenely
expensive.

However, subtracting the overhead will still skew the numbers somewhat
by giving more breathing time for memory and IO prefetching
mechanisms. Another option to consider would be to add a sampling
based mechanism for low overhead time attribution. It would be even
better if we could distinguish between time spent waiting on locks vs.
waiting on IO vs. waiting to be scheduled vs. actually executing.

[1] https://github.com/torvalds/linux/blob/master/arch/x86/vdso/vclock_gettime.c#L223

Regards,
Ants Aasma
--
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Rohit Goyal
Дата:
Сообщение: Re: Error in running DBT2
Следующее
От: Robert Haas
Дата:
Сообщение: Re: gettimeofday is at the end of its usefulness?