delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/06/09/07:54:07

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=jpsFThKZjhcJlGrIRPTSbUZWcqpYv+iTwsmzDdpok2tl9GnC2EdnD
g+licylCojU3BQ+P9OJP/5u2X/raBBiOOcjvDuSdeqnsD416dR9YZXuzH7J7E3VC
im/n6cih2IN/dosqYH4/6KrP1SJnZazg1Zv9/FUwdgFMDVDmhvbcGc=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=5TnKEsWqcACGf5EtYVOs8LP6P1s=; b=wZejETPE1jr3TQyznOtzT+zL3dIj
m4+T/9FDXR6WlJblfzHV1aOeDxZ/xRTutDO7wqhuzEwT3uzSBrU7Uze6vKqg8xQT
Y0jzEnQMVC2yTdWzdEG/R5Lny/7Bh8NAfPoz3TjwwA4mAEO99uKlgjBQb2eV6wDT
+DS3jkwdNIWjB20=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1
Date: Sun, 9 Jun 2013 13:53:51 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: GetSystemTimePreciseAsFileTime (was Re: [ANNOUNCEMENT] Updated: Cygwin 1.7.19)
Message-ID: <20130609115351.GF12283@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <announce DOT 20130605093949 DOT GA3250 AT calimero DOT vinschen DOT de> <51AF530A DOT 7080306 AT shaddybaddah DOT name> <20130605162825 DOT GC3250 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20130605162825.GC3250@calimero.vinschen.de>
User-Agent: Mutt/1.5.21 (2010-09-15)

On Jun  5 18:28, Corinna Vinschen wrote:
> On Jun  6 01:02, Shaddy Baddah wrote:
> > On 2013-06-05 19:39+1000, Corinna Vinschen wrote:
> > >- Drop support for Windows 2000 and Windows XP pre-SP3.
> > 
> > I find this change interesting. In no way am I complaining about this,
> > releases matching the above are well past end-of-life anyway.
> > 
> > But I am curious about the technical reason (and perhaps discussion)
> > that ruled Win 2K out.
> > [...]
> [...]
> There's also stuff we still not use a lot, foremost the Win32 API call
> CancelSynchronousIo which, if it had been introduced in NT4 already,
> would be probably heavily used by Cygwin (think signal handling).
> The next big thing developement-wise is not Windows 7, but Windows 8 (of
> all things!), because of the new GetSystemTimePreciseAsFileTime call,
> which I'm going to introduce into Cygwin pretty soon.

Or not.  I just tested the GetSystemTimePreciseAsFileTime call and it's
a wonderful performance killer.

Below I pasted my simple testcase.  It computes the average number of
CPU cycles per call to compare GetSystemTimeAsFileTime and
GetSystemTimePreciseAsFileTime with each other.

I tested the call on two 64 bit Windows 8 systems, one real machine,
one QEMU/KVM based virtual machine.  On real hardware I get:

On the virtual machine, the results are:

  Best case:

       8 cycles for GetSystemTimeAsFileTime
   15557 cycles for GetSystemTimePreciseAsFileTime

  Worst case under load:

      20 cycles for GetSystemTimeAsFileTime
   17443 cycles for GetSystemTimePreciseAsFileTime

On real hardware, the results are much better, but the difference between
GetSystemTimeAsFileTime and GetSystemTimePreciseAsFileTime are still
terrible:

  Best case:

       9 cycles for GetSystemTimeAsFileTime
    2761 cycles for GetSystemTimePreciseAsFileTime

  Worst case under load:

      18 cycles for GetSystemTimeAsFileTime
    5874 cycles for GetSystemTimePreciseAsFileTime


Corinna


#include <stdio.h>
#include <stdint.h>
#include <windows.h>

void (WINAPI *pGetSystemTimeAsFileTime) (LPFILETIME);
void (WINAPI *pGetSystemTimePreciseAsFileTime) (LPFILETIME);

static inline uint64_t
rdtsc(void)
{
  uint32_t low, high;

  __asm __volatile("rdtsc" : "=a" (low), "=d" (high));
  return (low | ((uint64_t)high << 32));
}

static void
cycle (void (WINAPI *f) (LPFILETIME), const char *name)
{
  const int iter = 1000000;
  int i;
  uint64_t v;
  FILETIME l;

  v = rdtsc ();
  for (i = 0; i < iter; i++)
    f (&l);
  v = rdtsc () - v;
  v /= iter;
  printf ("%6lld cycles for %s\n", v, name);
}

int main ()
{
  HMODULE h = GetModuleHandle ("kernel32.dll");
  pGetSystemTimeAsFileTime = (void (WINAPI *)(LPFILETIME))
  			GetProcAddress (h, "GetSystemTimeAsFileTime");
  pGetSystemTimePreciseAsFileTime = (void (WINAPI *)(LPFILETIME))
  			GetProcAddress (h, "GetSystemTimePreciseAsFileTime");
  if (!pGetSystemTimePreciseAsFileTime)
    {
      fputs ("GetSystemTimePreciseAsFileTime unsupported\n", stderr);
      return 1;
    }

  cycle (pGetSystemTimeAsFileTime, "GetSystemTimeAsFileTime");
  cycle (pGetSystemTimePreciseAsFileTime, "GetSystemTimePreciseAsFileTime");

  return 0;
}

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019