Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2025-11-15
10:07 • New ticket [7e47f55993] MS-Win Time: why not use GetSystemTimePreciseAsFileTime(... artifact: 6549447cdf user: oehhar
2025-11-03
14:34 • Ticket [1238d4fdb0] MS-Win Time: QueryPerformanceFrequency does not return NULL ... artifact: e9592d2d59 user: oehhar
14:31
[1238d4fd] Restore panic. closed check-in: c39d459072 user: oehhar tags: 1238d4fd-mswin-queryperformancefrequency
14:23 • Closed ticket [1238d4fdb0]: MS-Win Time: QueryPerformanceFrequency does not retu... artifact: f11872a45c user: oehhar
14:22 • Ticket [1238d4fdb0]: 3 changes artifact: 7efa15be74 user: oehhar
13:52 • Ticket [1238d4fdb0]: 3 changes artifact: 805086b908 user: sebres
08:26 • Ticket [1238d4fdb0]: 4 changes artifact: 95d5080546 user: oehhar
08:24
[1238d4fd] Replace Tcl_Panic by assert. check-in: d468a678d1 user: oehhar tags: 1238d4fd-mswin-queryperformancefrequency
2025-11-02
10:10 • Ticket [1238d4fdb0] MS-Win Time: QueryPerformanceFrequency does not return NULL ... artifact: a784a9977d user: apnadkarni
2025-11-01
18:37 • Ticket [1238d4fdb0]: 5 changes artifact: 37dced9f48 user: oehhar
18:28
[1238d4fd] MS-Win QueryPerformanceFrequency always succeeds since Win XP - this panics due to timeIn... check-in: 7a350b5f95 user: oehhar tags: 1238d4fd-mswin-queryperformancefrequency
18:05 • Ticket [1238d4fdb0] MS-Win Time: QueryPerformanceFrequency does not return NULL ... artifact: 59c223f5bb user: oehhar
12:54 • New ticket [1238d4fdb0]. artifact: ca011eada4 user: oehhar

MS-Win Time: QueryPerformanceFrequency does not return NULL since Win XP -> remove legacy code

Closed1238d4fdb0a41e6912b353a03732a001a1351850Created 1 year agoUpdated 1 year ago
Descriptionwiki2025-11-01 12:54:33
Following this description:

https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency

the command "QueryPerformanceFrequency" never retruns NULL since WIndows XP. So, we can assume for 9.1 to always get a non-null.

Some code in tclWinTime.c may be removed.

Same for QueryPerformanceCounter https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter

Thanks, Harald

Referenced by1
  • 6549447cdfNew ticket [7e47f55993] MS-Win Time: why not use GetSystemTimePreciseAsFileTime(). ticket2025-11-15 10:07:56
oehhar Ticket [1238d4fdb0]: 3 changes [History diff]2025-11-01 18:05:53
oehharwiki2025-11-01 18:37:46

Implemented by checkin [7a350b5f95] starting branch [1238d4fd-mswin-queryperformancefrequency].

If I run the timer.test file, it panics in line 780: https://core.tcl-lang.org/tcl/file?udc=1&ln=on&name=win%2FtclWinTime.c&ln=780 (I don't know how to show a file of a distinct branch, this is apparently the last commited branch)

I have added this panic, as the description says, that this should never happen. Ok.

Sorry, Wizard questions for Sergey, Jan, Ashok:

  • Is this generally a good idea?
  • Do we still need the calibration thread which runs each second?
  • Is the deleted part about Pentium 4 really outdated? Line 470-505 of main branch.

Thanks for all, Harald

apnadkarnimarkdown2025-11-02 10:10:29

Harald, there was a missing initialization in your changes that caused the panic. Kudos for being paranoid and including that check!

Fixed in your branch. timer.test passes

Sergey is obviously the best person to answer your queries, but my opinions -

  • Good idea? I'm all for removing obsolete/dead code.

  • Need for calibration thread - I would imagine we still need it. Nothing has changed in that regard, has it?

  • Pentium 4 - I seriously doubt any recent Windows (Win7 on) will run on it and would think it is safe to remove.

/Ashok

oehharwiki2025-11-03 08:26:31

Thanks, Ashok, great. Sorry, my fault, to have removed the initialisation.

I have replaced the panic by an assert in commit [d468a678d1].

I think, this can be merged now.

We always use the high performance timers now on Windows.

Thanks, Harald

sebreswiki2025-11-03 13:52:26

Regarding not-zero return code of QPF/QPC, I'm unsure - the docu says also "if the installed hardware supports a high-resolution performance counter"... And IIRC, a VM may lack high-resolution performance counters if the underlying hypervisor or specific monitoring tools are not configured correctly or are missing certain drivers, so maybe it is too hard to remove it.

As regards the calibration thread - I removed it in [fdfbd5e10] (rewritten windows high-resolution time completely without calibration thread), so however it is indeed unneeded, but certain internal adjustment is necessary to avoid "heavy" time drifts (basically part of calibration moved to time API and invoked at some circumstances by any thread to adjust QPC timer to low-resolution clock).

oehharplain2025-11-03 14:22:58
Thanks, Sergey, I have hoped (and feared) your reponse.
"1000 times faster".
But nobody will ever touch it, as we have nobody who understands only 5 % of it.

So, your answer is: "do not merge".

I respect this, no problem.
Neverhteless, I read the documentation differently. IMHO, there is a clear statement, that the two functions will never return NULL starting with Windows XP.

If would be sooo great to rewrite all this, but I see no hope, sorry.

Thanks for all,
Harald
oehhar Closed ticket [1238d4fdb0]. [History diff]2025-11-03 14:23:14
oehharwiki2025-11-03 14:34:36

Restored Tcl_Panic by [c39d459072] as seen as critical.

Closed ticket and branch as seen as not safe for VMs.

Thanks for all and take care, Harald

Log in (anonymous is fine) to add a comment.