pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: [PERFORM] Help with tuning this query (with
16+ messages / 8 participants
[nested] [flat]
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-07 16:29 John A Meinel <john@arbash-meinel.com>
0 siblings, 1 reply; 16+ messages in thread
From: John A Meinel @ 2005-03-07 16:29 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
Tom Lane wrote:
>"Magnus Hagander" <mha@sollentuna.net> writes:
>
>
>>There is. I beleive QueryPerformanceCounter has sub-mirosecond
>>resolution.
>>
>>
>>Can we just replace gettimeofday() with a version that's basically:
>>
>>
>
>No, because it's also used for actual time-of-day calls. It'd be
>necessary to hack executor/instrument.c in particular.
>
> regards, tom lane
>
>
It seems that there are 2 possibilities. Leave gettimeofday as it is,
and then change code that calls it for deltas with a
"pg_get_high_res_delta_time()", which on most platforms is just
gettimeofday, but on win32 is a wrapper for QueryPerformanceCounter().
Or we modify the win32 gettimeofday call to something like:
gettimeofday(struct timeval *tv, struct timezone *tz)
{
static int initialized = 0;
static LARGE_INTEGER freq = {0};
static LARGE_INTEGER base = {0};
static struct time_t base_tm = {0};
LARGE_INTEGER now = {0};
int64_t delta_secs = 0;
if(!initialized) {
QueryPerformanceFrequency(&freq);
base_tm = time(NULL); // This can be any moderately accurate time
function, maybe getlocaltime if it exists
QueryPerformanceCounter(&base);
}
QueryPerformanceCounter(&now);
delta_secs = now.QuadPart - base.QuadPart;
tv->tv_sec = delta_secs / freq.QuadPart;
delta_secs -= *tv.tv_sec * freq.QuadPart;
tv->tv_usec = delta_secs * 1000000 / freq.QuadPart
tv->tv_sec += base_tm;
return 0;
}
Attachments:
signature.asc (application/pgp-signature, 255B) download
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-07 17:24 John A Meinel <john@arbash-meinel.com>
parent: John A Meinel <john@arbash-meinel.com>
0 siblings, 1 reply; 16+ messages in thread
From: John A Meinel @ 2005-03-07 17:24 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
Tom Lane wrote:
>John A Meinel <john@arbash-meinel.com> writes:
>
>
>>>>Can we just replace gettimeofday() with a version that's basically:
>>>>
>>>>
>>>No, because it's also used for actual time-of-day calls. It'd be
>>>necessary to hack executor/instrument.c in particular.
>>>
>>>
>
>
>
>>Or we modify the win32 gettimeofday call to something like:
>>
>>
>
>That's what Magnus was talking about, but it's really no good because
>it would cause Postgres' now() function to fail to track post-boot-time
>changes in the system date setting. Which I think would rightly be
>considered a bug.
>
>The EXPLAIN ANALYZE instrumentation code will really be happier with a
>straight time-since-bootup counter; by using gettimeofday, it is
>vulnerable to giving wrong answers if someone changes the date setting
>while the EXPLAIN is running. But there is (AFAIK) no such call among
>the portable Unix syscalls. It seems reasonable to me to #ifdef that
>code to make use of QueryPerformanceCounter on Windows. This does not
>mean we want to alter the behavior of gettimeofday() where it's being
>used to find out the time of day.
>
> regards, tom lane
>
>
>
What if you changed the "initialized" to
if (count & 0xFF == 0) {
count = 1;
// get the new time of day
}
++count;
Then we would only be wrong for 256 gettimeofday calls. I agree it isn't
great, though. And probably better to just abstract (possibly just with
#ifdef) the calls for accurate timing, from the calls that actually need
the real time.
John
=:->
Attachments:
signature.asc (application/pgp-signature, 255B) download
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-07 18:05 Greg Stark <gsstark@mit.edu>
parent: John A Meinel <john@arbash-meinel.com>
0 siblings, 0 replies; 16+ messages in thread
From: Greg Stark @ 2005-03-07 18:05 UTC (permalink / raw)
To: John A Meinel <john@arbash-meinel.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
John A Meinel <john@arbash-meinel.com> writes:
> Then we would only be wrong for 256 gettimeofday calls. I agree it isn't
> great, though. And probably better to just abstract (possibly just with
> #ifdef) the calls for accurate timing, from the calls that actually need
> the real time.
What would be really neato would be to use the rtdsc (sp?) or equivalent
assembly instruction where available. Most processors provide such a thing and
it would give much lower overhead and much more accurate answers.
The main problem I see with this would be on multi-processor machines.
(QueryPerformanceCounter does work properly on multi-processor machines,
right?)
--
greg
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-07 22:30 Dave Held <dave.held@arrayservicesgrp.com>
0 siblings, 1 reply; 16+ messages in thread
From: Dave Held @ 2005-03-07 22:30 UTC (permalink / raw)
To: Greg Stark <gsstark@mit.edu>; John A Meinel <john@arbash-meinel.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
> -----Original Message-----
> From: Greg Stark [mailto:gsstark@mit.edu]
> Sent: Monday, March 07, 2005 12:06 PM
> To: John A Meinel
> Cc: Tom Lane; Magnus Hagander; Ken Egervari;
> pgsql-performance@postgresql.org; pgsql-hackers-win32@postgresql.org
> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning
> this query (with
> [...]
> What would be really neato would be to use the rtdsc (sp?) or
> equivalent assembly instruction where available. Most processors
> provide such a thing and it would give much lower overhead and much
> more accurate answers.
>
> The main problem I see with this would be on multi-processor
> machines. (QueryPerformanceCounter does work properly on
> multi-processor machines, right?)
I believe QueryPerformanceCounter() already does this.
__
David B. Held
Software Engineer/Array Services Group
200 14th Ave. East, Sartell, MN 56377
320.534.3637 320.253.7800 800.752.8129
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-07 22:48 John A Meinel <john@arbash-meinel.com>
0 siblings, 1 reply; 16+ messages in thread
From: John A Meinel @ 2005-03-07 22:48 UTC (permalink / raw)
To: Dave Held <dave.held@arrayservicesgrp.com>; +Cc: pgsql-performance; pgsql-hackers-win32@postgresql.org
Dave Held wrote:
>There is always clock(). It's mandated by ANSI C, but my docs say
>that POSIX requires CLOCKS_PER_SEC == 1000000 regardless of actual
>timer resolution, which seems a little brain-dead to me.
>
>__
>David B. Held
>
>
My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and
it had a resolution of 55clocks / s. When I just did this:
int main(int argc, char **argv)
{
int start = clock();
int now = start;
cout << "Clock: " << CLOCKS_PER_SEC << endl;
for(int i = 0; i < 10; ++i) {
while(now == clock()) {
// Do nothing
}
now = clock();
cout << now-start << "\t" << (now - start) / (double)
CLOCKS_PER_SEC << endl;
}
}
I got:
Clock: 1000
16 0.016
31 0.031
47 0.047
62 0.062
78 0.078
93 0.093
109 0.109
125 0.125
141 0.141
156 0.156
Which is about 1/0.016 = 62.5 clocks per second.
I'm pretty sure this is slightly worse than what we want. :)
It might be better on other platforms, but on win32 clock() is most
definitely *not* what you want.
John
=:->
Attachments:
signature.asc (application/pgp-signature, 252B) download
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-07 22:56 Tom Lane <tgl@sss.pgh.pa.us>
parent: John A Meinel <john@arbash-meinel.com>
0 siblings, 1 reply; 16+ messages in thread
From: Tom Lane @ 2005-03-07 22:56 UTC (permalink / raw)
To: John A Meinel <john@arbash-meinel.com>; +Cc: Dave Held <dave.held@arrayservicesgrp.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
John A Meinel <john@arbash-meinel.com> writes:
> Dave Held wrote:
>> There is always clock().
> My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and
> it had a resolution of 55clocks / s. When I just did this:
The other problem is it measures process CPU time, not elapsed time
which is probably more significant for our purposes.
Which brings up a question: just what does QueryPerformanceCounter
measure?
regards, tom lane
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-07 23:08 Dave Page <dpage@vale-housing.co.uk>
0 siblings, 0 replies; 16+ messages in thread
From: Dave Page @ 2005-03-07 23:08 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; John A Meinel <john@arbash-meinel.com>; +Cc: Dave Held <dave.held@arrayservicesgrp.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
> -----Original Message-----
> From: pgsql-hackers-win32-owner@postgresql.org
> [mailto:pgsql-hackers-win32-owner@postgresql.org] On Behalf
> Of Tom Lane
> Sent: 07 March 2005 22:57
> To: John A Meinel
> Cc: Dave Held; pgsql-performance@postgresql.org;
> pgsql-hackers-win32@postgresql.org
> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning
> this query (with
>
> Which brings up a question: just what does QueryPerformanceCounter
> measure?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/w
inui/windowsuserinterface/windowing/timers/abouttimers.asp says:
If a high-resolution performance counter exists on the system, you can
use the QueryPerformanceFrequency function to express the frequency, in
counts per second. The value of the count is processor dependent. On
some processors, for example, the count might be the cycle rate of the
processor clock.
The QueryPerformanceCounter function retrieves the current value of the
high-resolution performance counter. By calling this function at the
beginning and end of a section of code, an application essentially uses
the counter as a high-resolution timer. For example, suppose that
QueryPerformanceFrequency indicates that the frequency of the
high-resolution performance counter is 50,000 counts per second. If the
application calls QueryPerformanceCounter immediately before and
immediately after the section of code to be timed, the counter values
might be 1500 counts and 3500 counts, respectively. These values would
indicate that .04 seconds (2000 counts) elapsed while the code executed.
Regards, Dave.
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-07 23:15 Greg Stark <gsstark@mit.edu>
parent: Dave Held <dave.held@arrayservicesgrp.com>
0 siblings, 0 replies; 16+ messages in thread
From: Greg Stark @ 2005-03-07 23:15 UTC (permalink / raw)
To: Dave Held <dave.held@arrayservicesgrp.com>; +Cc: Greg Stark <gsstark@mit.edu>; John A Meinel <john@arbash-meinel.com>; Tom Lane <tgl@sss.pgh.pa.us>; Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
"Dave Held" <dave.held@arrayservicesgrp.com> writes:
> > What would be really neato would be to use the rtdsc (sp?) or
> > equivalent assembly instruction where available. Most processors
> > provide such a thing and it would give much lower overhead and much
> > more accurate answers.
> >
> > The main problem I see with this would be on multi-processor
> > machines. (QueryPerformanceCounter does work properly on
> > multi-processor machines, right?)
>
> I believe QueryPerformanceCounter() already does this.
This would be a good example of why selectively quoting the part of the
message to which you're responding to is more useful than just blindly echoing
my message back to me.
Already does what?
Use rtdsc? In which case using it would be a mistake. Since rtdsc doesn't work
across processors. And using it via QueryPerformanceCounter would be a
non-portable approach to using rtdsc. Much better to devise a portable
approach that works on any architecture where something equivalent is
available.
Or already works on multi-processor machines? In which case, uh, ok.
--
greg
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-08 00:11 Dave Held <dave.held@arrayservicesgrp.com>
0 siblings, 1 reply; 16+ messages in thread
From: Dave Held @ 2005-03-08 00:11 UTC (permalink / raw)
To: Greg Stark <gsstark@mit.edu>; +Cc: John A Meinel <john@arbash-meinel.com>; Tom Lane <tgl@sss.pgh.pa.us>; Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
> -----Original Message-----
> From: Greg Stark [mailto:gsstark@mit.edu]
> Sent: Monday, March 07, 2005 5:15 PM
> To: Dave Held
> Cc: Greg Stark; John A Meinel; Tom Lane; Magnus Hagander; Ken
> Egervari;
> pgsql-performance@postgresql.org; pgsql-hackers-win32@postgresql.org
> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning
> this query
> (with
>
> "Dave Held" <dave.held@arrayservicesgrp.com> writes:
>
> > > What would be really neato would be to use the rtdsc (sp?) or
> > > equivalent assembly instruction where available. Most
> > > processors provide such a thing and it would give much lower
> > > overhead and much more accurate answers.
> > >
> > > The main problem I see with this would be on multi-processor
> > > machines. (QueryPerformanceCounter does work properly on
> > > multi-processor machines, right?)
> >
> > I believe QueryPerformanceCounter() already does this.
> [...]
> Already does what?
>
> Use rtdsc?
Yes.
> In which case using it would be a mistake. Since rtdsc doesn't
> work across processors.
It doesn't always use RDTSC. I can't find anything authoritative on
when it does. I would assume that it would use RDTSC when available
and something else otherwise.
> And using it via QueryPerformanceCounter would be a non-portable
> approach to using rtdsc. Much better to devise a portable
> approach that works on any architecture where something equivalent
> is available.
How do you know that QueryPerformanceCounter doesn't use RDTSC
where available, and something appropriate otherwise? I don't see
how any strategy that explicitly executes RDTSC can be called
"portable".
> Or already works on multi-processor machines? In which case, uh, ok.
According to MSDN it does work on MP systems, and they say that "it
doesn't matter which CPU gets called".
__
David B. Held
Software Engineer/Array Services Group
200 14th Ave. East, Sartell, MN 56377
320.534.3637 320.253.7800 800.752.8129
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-08 00:29 Dave Held <dave.held@arrayservicesgrp.com>
0 siblings, 0 replies; 16+ messages in thread
From: Dave Held @ 2005-03-08 00:29 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; John A Meinel <john@arbash-meinel.com>; +Cc: pgsql-performance; pgsql-hackers-win32@postgresql.org
> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Monday, March 07, 2005 4:57 PM
> To: John A Meinel
> Cc: Dave Held; pgsql-performance@postgresql.org;
> pgsql-hackers-win32@postgresql.org
> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning
> this query
> (with
>
> John A Meinel <john@arbash-meinel.com> writes:
> > Dave Held wrote:
> >> There is always clock().
>
> > My experience with clock() on win32 is that CLOCKS_PER_SEC
> > was 1000, and it had a resolution of 55clocks / s.
Which is why I suggested QueryPerformanceCounter for Win32. I
only suggested clock() for *nix.
> The other problem is it measures process CPU time, not elapsed time
> which is probably more significant for our purposes.
Actually, the bigger problem is that a quick test of clock() on
Linux shows that it only has a maximum resolution of 10ms on my
hardware. Looks like gettimeofday() is the best choice.
> Which brings up a question: just what does QueryPerformanceCounter
> measure?
I think it measures raw CPU cycles, roughly, which seems like it
would more or less correspond to wall time.
__
David B. Held
Software Engineer/Array Services Group
200 14th Ave. East, Sartell, MN 56377
320.534.3637 320.253.7800 800.752.8129
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-08 01:37 Steinar H. Gunderson <sgunderson@bigfoot.com>
parent: Dave Held <dave.held@arrayservicesgrp.com>
0 siblings, 1 reply; 16+ messages in thread
From: Steinar H. Gunderson @ 2005-03-08 01:37 UTC (permalink / raw)
To: Dave Held <dave.held@arrayservicesgrp.com>; +Cc: Greg Stark <gsstark@mit.edu>; John A Meinel <john@arbash-meinel.com>; Tom Lane <tgl@sss.pgh.pa.us>; Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
On Mon, Mar 07, 2005 at 06:11:34PM -0600, Dave Held wrote:
>> In which case using it would be a mistake. Since rtdsc doesn't
>> work across processors.
> It doesn't always use RDTSC. I can't find anything authoritative on
> when it does. I would assume that it would use RDTSC when available
> and something else otherwise.
RDTSC is a bad source of information for this kind of thing, as the CPU
frequency might vary. Check your QueryPerformanceFrequency() -- most likely
it will not match your clock speed. I haven't tested on a lot of machines,
but I've never seen QueryPerformanceFrequency() ever match the clock speed,
which it most probably would if it was using RDTSC. (I've been told it uses
some other kind of timer available on most motherboards, but I don't know the
details.)
/* Steinar */
--
Homepage: http://www.sesse.net/
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-08 02:02 Tom Lane <tgl@sss.pgh.pa.us>
parent: Steinar H. Gunderson <sgunderson@bigfoot.com>
0 siblings, 1 reply; 16+ messages in thread
From: Tom Lane @ 2005-03-08 02:02 UTC (permalink / raw)
To: Steinar H. Gunderson <sgunderson@bigfoot.com>; +Cc: Dave Held <dave.held@arrayservicesgrp.com>; Greg Stark <gsstark@mit.edu>; John A Meinel <john@arbash-meinel.com>; Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
"Steinar H. Gunderson" <sgunderson@bigfoot.com> writes:
> RDTSC is a bad source of information for this kind of thing, as the CPU
> frequency might vary.
One thought that was bothering me was that if the CPU goes idle while
waiting for disk I/O, its clock might stop or slow down dramatically.
If we believed such a counter for EXPLAIN, we'd severely understate
the cost of disk I/O.
I dunno if that is the case on any Windows hardware or not, but none
of this thread is making me feel confident that we know what
QueryPerformanceCounter does measure.
regards, tom lane
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-08 02:06 Steinar H. Gunderson <sgunderson@bigfoot.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 16+ messages in thread
From: Steinar H. Gunderson @ 2005-03-08 02:06 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Dave Held <dave.held@arrayservicesgrp.com>; Greg Stark <gsstark@mit.edu>; John A Meinel <john@arbash-meinel.com>; Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
On Mon, Mar 07, 2005 at 09:02:38PM -0500, Tom Lane wrote:
> One thought that was bothering me was that if the CPU goes idle while
> waiting for disk I/O, its clock might stop or slow down dramatically.
> If we believed such a counter for EXPLAIN, we'd severely understate
> the cost of disk I/O.
>
> I dunno if that is the case on any Windows hardware or not, but none
> of this thread is making me feel confident that we know what
> QueryPerformanceCounter does measure.
I believe the counter is actually good in such a situation -- I'm not a Win32
guru, but I believe it is by far the best timer for measuring, well,
performance of a process like this. After all, it's what it was designed to
be :-)
OBTW, I think I can name something like 15 or 20 different function calls to
measure time in the Win32 API (all of them in use); it really is a giant
mess.
/* Steinar */
--
Homepage: http://www.sesse.net/
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-08 03:51 PFC <lists@boutiquenumerique.com>
parent: Steinar H. Gunderson <sgunderson@bigfoot.com>
0 siblings, 0 replies; 16+ messages in thread
From: PFC @ 2005-03-08 03:51 UTC (permalink / raw)
To: Steinar H. Gunderson <sgunderson@bigfoot.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Dave Held <dave.held@arrayservicesgrp.com>; Greg Stark <gsstark@mit.edu>; John A Meinel <john@arbash-meinel.com>; Magnus Hagander <mha@sollentuna.net>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
From the Linux Kernel (make menuconfig) there seem to be two new reliable
sources for timing information. Note the remark about "Time Stamp Counter"
below. Question is, which one of these (or others) are your API functions
using ? I have absolutely no idea !
CONFIG_HPET_TIMER:
This enables the use of the HPET for the kernel's internal timer.
HPET is the next generation timer replacing legacy 8254s.
You can safely choose Y here. However, HPET will only be
activated if the platform and the BIOS support this feature.
Otherwise the 8254 will be used for timing services.
Choose N to continue using the legacy 8254 timer.
Symbol: HPET_TIMER [=y]
Prompt: HPET Timer Support
Defined at arch/i386/Kconfig:440
Location:
-> Processor type and features
CONFIG_X86_PM_TIMER:
The Power Management Timer is available on all
ACPI-capable, in most cases even if
ACPI is unusable or blacklisted.
This timing source is not affected by powermanagement
features like aggressive processor
idling, throttling, frequency and/or
voltage scaling, unlike the commonly used Time Stamp
Counter (TSC) timing source.
So, if you see messages like 'Losing too many ticks!' in
the kernel logs, and/or you are using
this on a notebook which does not
yet have an HPET, you should say "Y" here.
Symbol: X86_PM_TIMER
[=y]
Prompt: Power Management Timer
Support
Defined at
drivers/acpi/Kconfig:319
Depends on: !X86_VOYAGER && !X86_VISWS && !IA64_HP_SIM && (IA64 || X86) &&
X86 && ACPI && ACPI_
Location:
-> Power management options (ACPI,
APM) -> ACPI
(Advanced Configuration and Power Interface)
Support -> ACPI Support (ACPI [=y])
On Tue, 08 Mar 2005 03:06:24 +0100, Steinar H. Gunderson
<sgunderson@bigfoot.com> wrote:
> On Mon, Mar 07, 2005 at 09:02:38PM -0500, Tom Lane wrote:
>> One thought that was bothering me was that if the CPU goes idle while
>> waiting for disk I/O, its clock might stop or slow down dramatically.
>> If we believed such a counter for EXPLAIN, we'd severely understate
>> the cost of disk I/O.
>>
>> I dunno if that is the case on any Windows hardware or not, but none
>> of this thread is making me feel confident that we know what
>> QueryPerformanceCounter does measure.
>
> I believe the counter is actually good in such a situation -- I'm not a
> Win32
> guru, but I believe it is by far the best timer for measuring, well,
> performance of a process like this. After all, it's what it was designed
> to
> be :-)
>
> OBTW, I think I can name something like 15 or 20 different function
> calls to
> measure time in the Win32 API (all of them in use); it really is a giant
> mess.
>
> /* Steinar */
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-08 04:35 John A Meinel <john@arbash-meinel.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 16+ messages in thread
From: John A Meinel @ 2005-03-08 04:35 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Dave Held <dave.held@arrayservicesgrp.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
Tom Lane wrote:
>John A Meinel <john@arbash-meinel.com> writes:
>
>
>>Dave Held wrote:
>>
>>
>>>There is always clock().
>>>
>>>
>
>
>
>>My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and
>>it had a resolution of 55clocks / s. When I just did this:
>>
>>
>
>The other problem is it measures process CPU time, not elapsed time
>which is probably more significant for our purposes.
>
>Which brings up a question: just what does QueryPerformanceCounter
>measure?
>
> regards, tom lane
>
>
clock() according to the Visual Studio Help measures wall clock time.
But you're right, POSIX says it is approximation of processor time.
The docs don't say specifically what QueryPerformanceCounter() measures,
but states
> The *QueryPerformanceCounter* function retrieves the current value of
> the high-resolution performance counter.
>
It also states:
>
> Remarks
>
> On a multiprocessor machine, it should not matter which processor is
> called. However, you can get different results on different processors
> due to bugs in the BIOS or the HAL. To specify processor affinity for
> a thread, use the *SetThreadAffinityMask* function.
>
So it sounds like it is actually querying some counter independent of
processing.
In fact, there is also this statement:
> *QueryPerformanceFrequency*
>
> The QueryPerformanceFrequency function retrieves the frequency of the
> high-resolution performance counter, if one exists. The frequency
> cannot change while the system is running.
>
If that is accurate, it would make QueryPerformanceCounter independent
of things like speed stepping, etc. So again, it sounds independent of
processing.
John
=:->
Attachments:
signature.asc (application/pgp-signature, 252B) download
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: [PERFORM] Help with tuning this query (with
@ 2005-03-08 09:05 Magnus Hagander <mha@sollentuna.net>
0 siblings, 0 replies; 16+ messages in thread
From: Magnus Hagander @ 2005-03-08 09:05 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Steinar H. Gunderson <sgunderson@bigfoot.com>; +Cc: Dave Held <dave.held@arrayservicesgrp.com>; Greg Stark <gsstark@mit.edu>; John A Meinel <john@arbash-meinel.com>; Ken Egervari <ken@upfactor.com>; pgsql-performance; pgsql-hackers-win32@postgresql.org
> > RDTSC is a bad source of information for this kind of thing, as the
> > CPU frequency might vary.
>
> One thought that was bothering me was that if the CPU goes
> idle while waiting for disk I/O, its clock might stop or slow
> down dramatically.
> If we believed such a counter for EXPLAIN, we'd severely
> understate the cost of disk I/O.
>
> I dunno if that is the case on any Windows hardware or not,
> but none of this thread is making me feel confident that we
> know what QueryPerformanceCounter does measure.
I'm "reasonaly confident" that QPC will measure actual wallclock time as
passed, using a chip that is external to the CPU. (Don't ask me which
chip :P).
The docs specifically say: "Note that the frequency of the
high-resolution performance counter is not the processor speed."
It also indicates that it is possible for hardware not to support it, in
which case the frequency will be reported as zero. I don't know any
remotely modern wintel system that doesn't, though - it seems this may
be referring to the old MIPS port of NT that didn't have it.
I also find:
"Depending on the processor and exact version of NT you're using, on an
Intel you get either the Time Stamp Counter, or the 1.1... MHz timer
built into the motherboard."
So I think we're perfectly safe relying on it. And certainly not alone
in doing so :-)
//Magnus
^ permalink raw reply [nested|flat] 16+ messages in thread
end of thread, other threads:[~2005-03-08 09:05 UTC | newest]
Thread overview: 16+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-07 16:29 Re: [PERFORM] Help with tuning this query (with John A Meinel <john@arbash-meinel.com>
2005-03-07 17:24 ` John A Meinel <john@arbash-meinel.com>
2005-03-07 18:05 ` Greg Stark <gsstark@mit.edu>
2005-03-07 22:30 Re: [PERFORM] Help with tuning this query (with Dave Held <dave.held@arrayservicesgrp.com>
2005-03-07 23:15 ` Greg Stark <gsstark@mit.edu>
2005-03-07 22:48 Re: [PERFORM] Help with tuning this query (with John A Meinel <john@arbash-meinel.com>
2005-03-07 22:56 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-03-08 04:35 ` John A Meinel <john@arbash-meinel.com>
2005-03-07 23:08 Re: [PERFORM] Help with tuning this query (with Dave Page <dpage@vale-housing.co.uk>
2005-03-08 00:11 Re: [PERFORM] Help with tuning this query (with Dave Held <dave.held@arrayservicesgrp.com>
2005-03-08 01:37 ` Steinar H. Gunderson <sgunderson@bigfoot.com>
2005-03-08 02:02 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-03-08 02:06 ` Steinar H. Gunderson <sgunderson@bigfoot.com>
2005-03-08 03:51 ` PFC <lists@boutiquenumerique.com>
2005-03-08 00:29 Re: [PERFORM] Help with tuning this query (with Dave Held <dave.held@arrayservicesgrp.com>
2005-03-08 09:05 Re: [PERFORM] Help with tuning this query (with Magnus Hagander <mha@sollentuna.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox