[Bug] time(0x0) call extremely slow?

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Sun Jan 19 16:38:41 GMT 2025


On 2025-01-19 05:55, Devste Devste via Cygwin wrote:
> strace -o strace.log dirname -- /some/path/here
> 
> Cygwin via Git for Windows 2.47.x
> Windows 10
> 
> I see:
>> 3249 60966 [main] dirname 31200 time: 1736590460 = time(0x0)
> 
> On average it shows between 2000-4000 duration (I'm using Cloudflare's
> ntp servers) which seems fishy to me, as this shouldn't be that slow?

Remember this is a C program, running under C++ program strace, running under a 
C++ emulator cygwin, where other processes can run, including overhead which 
includes its own timing calls, and I don't believe strace takes account of that, 
so you are seeing wall clock durations and time counters, in µs I believe.

I see these times, normally ~200us, although I do not know why time is being 
called in dirname?

$ grep time ../dirname.strace
   218   27334 [main] dirname (2604) time: 1737301093 = time(0x0)
   181   29475 [main] dirname (2604) time: 1737301093 = time(0x0)
  4352  101621 [main] dirname 50118 time: 1737301093 = time(0x0)

These all appear to be converted from SystemTimePreciseAsFileTime; for accurate 
timing, you probably have to use rdtsc instructions directly to capture the 
times in a buffer; and calibrate using SystemTimePreciseAsFileTime, and do any 
conversions, after the fact.

[Unless you are running a local Windows NTP server to discipline the time, w32tm 
service with DC time, or upstream remote NTP servers, are mostly irrelevant as 
they randomly bump the system time towards UTC.]

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


More information about the Cygwin mailing list