Tcl Source Code

View Ticket
Login
Ticket UUID: 52fd7694564161f7a1ee24b073a5af8cf5675e08
Title: cmdMZ-6.6 fails on low performance system
Type: Bug Created on: 2023-06-26 01:02:57
Submitter: chrstphrchvz Assigned to: nobody
Subsystem: 06. Time Measurement Severity: Minor
Priority: 5 Medium Last modified: 2026-10-20 13:46:54
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: 8.6.13
Description:

In cmdMZ.test, _nrt_sleep 0.01 should take at least 10µs to run. But cmdMZ-6.6 assumes that timerate {_nrt_sleep 0.01} 50 will run _nrt_sleep 0.01 more than 500 times, with an average time less than 100µs and at a rate greater than 10000 times per second; this is not the case on one of my systems which is running IA-32 (32-bit x86) Linux on a single-core 1.73GHz Pentium M. Are such performance requirements truly necessary for this test?

==== cmdMZ-6.6 Tcl_TimeRateObjCmd: slower commands take longer, but it remains almost the same time of measument FAILED
==== Contents of test case:
set m1 [timerate {_nrt_sleep 0.01} 50] set m2 [timerate {_nrt_sleep 1.00} 50] list [list \ [expr {[lindex $m1 0] < [lindex $m2 0]}] \ [expr {[lindex $m1 0] < 100}] \ [expr {[lindex $m2 0] > 100}] \ [expr {[lindex $m1 2] > 500}] \ [expr {[lindex $m2 2] < 500}] \ [expr {[lindex $m1 4] > 10000}] \ [expr {[lindex $m2 4] < 10000}] \ [expr {[lindex $m1 6] > 5 && [lindex $m1 6] < 100}] \ [expr {[lindex $m2 6] > 5 && [lindex $m2 6] < 100}] \ ] $m1 $m2; # interesting only in error case.
---- Result was: {1 0 1 0 1 0 1 1 1} {108.017 µs/# 463 # 9257.8 #/sec 50.012 net-ms} {1093.13 µs/# 46 # 914.80 #/sec 50.284 net-ms} ---- Result should have been (glob matching): {1 1 1 1 1 1 1 1 1} * ==== cmdMZ-6.6 FAILED

User Comments:
serhiy.storchaka added on 2026-10-20 13:46:54:

The thresholds are unchanged on main, 9.0 and 8.6: cmdMZ-6.6 requires the 10 µs case to cost less than 100 µs per call and to run more than 500 times at more than 10000/s, a fixed budget for the interpreter overhead.

A possible fix is to compare it with the 1 ms case instead (ideally 100 times faster; 5 times leaves room for slow systems):

-	[expr {[lindex $m1 0] < 100}] \
+	[expr {[lindex $m1 0] * 5 < [lindex $m2 0]}] \
-	[expr {[lindex $m1 2] > 500}] \
+	[expr {[lindex $m1 2] > [lindex $m2 2] * 5}] \
-	[expr {[lindex $m1 4] > 10000}] \
+	[expr {[lindex $m1 4] > [lindex $m2 4] * 5}] \
I could not reproduce the failure (my machine is too fast, also under valgrind), but your numbers pass these checks (108 vs 1093 µs/#, 463 vs 46 #, 9257 vs 914 #/sec).