Re: [pgsql-hackers-win32] Help with tuning this query (with - Mailing list pgsql-performance

From John A Meinel
Subject Re: [pgsql-hackers-win32] Help with tuning this query (with
Date
Msg-id 422C817A.8050009@arbash-meinel.com
Whole thread Raw
In response to Re: [pgsql-hackers-win32] Help with tuning this query (with explain analyze finally)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [pgsql-hackers-win32] Help with tuning this query (with explain analyze finally)
List pgsql-performance
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;
}


Attachment

pgsql-performance by date:

Previous
From:
Date:
Subject: Tuning, configuration for 7.3.5 on a Sun E4500
Next
From: Tom Lane
Date:
Subject: Re: [pgsql-hackers-win32] Help with tuning this query (with explain analyze finally)