Increase latency for big list test in defrag#2421
Conversation
Signed-off-by: Seungmin Lee <sungming@amazon.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #2421 +/- ##
============================================
+ Coverage 71.51% 71.53% +0.02%
============================================
Files 123 125 +2
Lines 67454 69214 +1760
============================================
+ Hits 48239 49513 +1274
- Misses 19215 19701 +486 🚀 New features to boost your workflow:
|
e0c1ba0 to
d8eed61
Compare
|
Do we understand what the rare slow downs are? If it's related to the system (perhaps valkey-server is getting descheduled) then I would expect every test to need this latency increase. If it's specific to just the lists, we probably should investigate that, since it's probably some type of bug. |
|
Let me check other tests too |
|
Fixes #2205? |
According to #2398 (comment) (and a linked Redis issue) it can be related to kernel versions. A kernel mitigation for some CVE. @arkamar might be able to explain more...(?) |
I am not sure it's specific to the OS/kernel version because I was able to get above latency on both Ubuntu 20.04 and 24.04 |
Can we consider increasing the default limit latency to valkey/tests/unit/memefficiency.tcl Lines 173 to 175 in 34480ac |
Yes, good idea. |
Signed-off-by: Seungmin Lee <sungming@amazon.com>
This doesn't seem related. The original issue that was identified by arkamar is for timeouts, where as this is just taking slightly longer times. |
Setting it to 30ms almost defeats the purpose of the latency testing. The goal was to verify that active defragmentation isn't introducing latency spikes, but it seems like it is. Maybe we should allow 1 data point above the threshold? |
I think that is also good idea but IMO, allowing 1 spike might not generalize across machines, environments, or workloads. Also, future contributors may misunderstand or misuse the logic (e.g., tolerating 1 or 2..), and if a single spike exceeds a drastically high value such as 1 second, it could still be allowed under this rule and go undetected |
|
Maybe instead we could add a debug option to use |
|
We are using the latency data reported by the server via the LATENCY command, which internally measures duration. Based on the implementation (defrag.c#L1165-L1190), I believe this provides sufficiently accurate duration. I also double checked the source of the latency, and it is coming from valkey/tests/unit/memefficiency.tcl Lines 118 to 137 in a50690f |
|
There may be other causes of latency spikes, such as synchronous IO, that also affect these tests? Such as |
I have a suspicion that it's related to the process being interrupted by the either the guest or host OS. The time will keep ticking up in those cases. We shouldn't be doing any synchronous IO in these tests. |
If this is true, we can't really do much about it, can we? Let's merge this PR for now to unflake the tests? |
I suggested we might be able to use the processor clock to actually track time used by the process. If that doesn't work, I think we should remove the latency check and create an issue for later. |
|
I am checking the cpu clock, will get the result soon |
|
I tested with CLOCK_PROCESS_CPUTIME_ID and other options like CLOCK_MONOTONIC, but the latency spikes still appear: To investigate further, I wrote a simple loop to compare the timing behavior across different clocks, CLOCK_PROCESS_CPUTIME_ID sometimes takes longer than others: I found similar issues from online indicating that CLOCK_PROCESS_CPUTIME_ID incurs more overhead, as it queries the scheduler subsystem (via syscall) for fine grained/per thread/process CPU usage. This makes it sometimes more expensive than wall time clocks. |
What you showed is all less than 1% differences, so I don't think that is causing the spike (the spike is on the order of 10000us) So, it seems like we still aren't sure what is causing the issue :/ I'm OK closing this. I'll make an issue to track it, and then we can merge this. EDIT: new issue #2444 |
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Across multiple runs of the big list test in defrag, the latency check
is tripping because the maximum observed defrag cycle latency
occasionally spikes above our 5 ms limit. While most cycles complete in
just a few milliseconds, rare slowdowns push some cycles into the double
digit millisecond range, so a 5 ms hard cap is too aggressive for stable
testing.
```
/runtest --verbose --tls --single unit/memefficiency --only '/big list' --accurate --loop --fastfail
```
```
[err]: Active Defrag big list: standalone in tests/unit/memefficiency.tcl
Expected 12 <= 5 (context: type proc line 18 cmd {assert {$max_latency <= $limit_ms}} proc ::validate_latency level 1)
(Fast fail: test will exit now)
[err]: Active Defrag big list: standalone in tests/unit/memefficiency.tcl
Expected 21 <= 5 (context: type proc line 18 cmd {assert {$max_latency <= $limit_ms}} proc ::validate_latency level 1)
(Fast fail: test will exit now)
[err]: Active Defrag big list: standalone in tests/unit/memefficiency.tcl
Expected 25 <= 5 (context: type proc line 18 cmd {assert {$max_latency <= $limit_ms}} proc ::validate_latency level 1)
(Fast fail: test will exit now)
[err]: Active Defrag big list: standalone in tests/unit/memefficiency.tcl
Expected 17 <= 5 (context: type proc line 18 cmd {assert {$max_latency <= $limit_ms}} proc ::validate_latency level 1)
(Fast fail: test will exit now)
```
---------
Signed-off-by: Seungmin Lee <sungming@amazon.com>
Co-authored-by: Seungmin Lee <sungming@amazon.com>
…40 (valkey-io#2574) Delete the out-of-date comment explaining why changed latency from 5 to 40 in valkey-io#2421 , which is a leftover of valkey-io#2553 Signed-off-by: Alina Liu <liusalisa6363@gmail.com>
…40 (valkey-io#2574) Delete the out-of-date comment explaining why changed latency from 5 to 40 in valkey-io#2421 , which is a leftover of valkey-io#2553 Signed-off-by: Alina Liu <liusalisa6363@gmail.com> Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
Across multiple runs of the big list test in defrag, the latency check is tripping because the maximum observed defrag cycle latency occasionally spikes above our 5 ms limit. While most cycles complete in just a few milliseconds, rare slowdowns push some cycles into the double digit millisecond range, so a 5 ms hard cap is too aggressive for stable testing.