| Ticket UUID: | 1238d4fdb0a41e6912b353a03732a001a1351850 | ||
| Title: | MS-Win Time: QueryPerformanceFrequency does not return NULL since Win XP -> remove legacy code | ||
| Type: | RFE | Created on: | 2025-11-01 12:54:33 |
| Submitter: | oehhar | Assigned to: | nobody |
| Subsystem: | 03. Timer Events | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2025-11-03 14:34:36 |
| Status: | Closed | Closed by: | oehhar |
| Resolution: | None | Closed on: | 2025-11-03 14:34:36 |
| Version: | main | ||
| Description: | ||||
|
Following this description: 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 | ||||
| User Comments: | ||||
oehhar added on 2025-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:
Thanks for all, Harald apnadkarni added on 2025-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 -
/Ashok oehhar added on 2025-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 sebres added on 2025-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). oehhar added on 2025-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 added on 2025-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 | ||||
