mirror of
https://github.com/redis/redis.git
synced 2026-05-28 04:02:46 -04:00
test: stabilize HOTKEYS MULTI/EXEC test by increasing iteration count (#15129)
## Problem The test `HOTKEYS - commands inside MULTI/EXEC` in `tests/unit/hotkeys.tcl` is flaky on fast hardware. This PR raises its inner loop count from 7 to 30 to make `key2` reliably appear in the CPU top-K. Failed CI: https://github.com/redis/redis/actions/runs/25051455424/job/73380034469?pr=15128 Inside `MULTI`/`EXEC`, each queued command's per-command CPU time is recorded as `c->duration = ustime() - call_timer` (microseconds, integer). Very fast commands such as `SET` against a small value can complete in less than 1 µs and therefore be measured as `0`. `hotkeyStatsUpdateCurrentCmd` then forwards that zero duration as the weight to `chkTopKUpdate`, which has an explicit early return on `weight == 0`: ```c sds chkTopKUpdate(chkTopK *topk, char *item, int itemlen, counter_t weight) { if (weight == 0) return NULL; ... } ``` In the original test, `key2` is `SET` only 7 times inside the transaction. On fast hosts (the failure was observed on an ARM box with `ustime()` ticking at 1 µs resolution) it is possible for all 7 calls to be measured as 0 µs, which means `key2` is never inserted into the CPU top-K and the assertion ```tcl assert [dict exists $cpu_result $key2] ``` fails. `key1` has 21 calls and is statistically safe. The author already anticipated this and left a comment ("Send multiple commands to avoid <1us cpu for $key2"), but 7 iterations turned out to be insufficient. ## Changes Bump the iteration count from 7 to 30. With `key2` now `SET` 30 times the probability of every single call being measured as 0 µs becomes negligible on any realistic hardware.
This commit is contained in:
parent
0bbb196c46
commit
417cc6e4fc
1 changed files with 1 additions and 1 deletions
|
|
@ -251,7 +251,7 @@ start_server {tags {external:skip "hotkeys"}} {
|
|||
r multi
|
||||
# Send multiple commands to avoid <1us cpu for $key2 which we assert
|
||||
# at end of test
|
||||
for {set i 0} {$i < 7} {incr i} {
|
||||
for {set i 0} {$i < 30} {incr i} {
|
||||
r set $key1 value1
|
||||
r set $key2 value1
|
||||
r set $key1 value2
|
||||
|
|
|
|||
Loading…
Reference in a new issue