Skip to content

Commit c792383

Browse files
gh-worker-dd-mergequeue-cf854d[bot]KowalskiThomastaegyunkim
authored
Merge pull request #132 from DataDog/kowalski/python_spiky-improve-expected-profile
[python_spiky] Improve expected profile Co-authored-by: KowalskiThomas <thomas.kowalski@datadoghq.com> Co-authored-by: taegyun.kim <taegyun.kim@datadoghq.com>
2 parents 42bc0a5 + 076e2a3 commit c792383

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

scenarios/python_spiky_3.11/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,20 @@ Two threads run concurrently for the same duration:
99
## Expected behavior
1010

1111
- **wall-time**: both threads contribute ~50% each, since both run for the same duration
12-
- **cpu-time**: only `cpu_work` appears (~90%+), since sleeping does not consume CPU
12+
- **cpu-time**: only `cpu_work` appears (~99%+), since sleeping does not consume CPU
13+
14+
## CPU usage over time
15+
16+
Execution alternates CPU spikes (busy-looping on `math.factorial`, ~100% CPU)
17+
with sleep periods (~0% CPU). Spike/sleep lengths are random, but each half of
18+
the run sums to `EXECUTION_TIME_SEC / 2`, so the mean CPU usage is exactly 50%.
19+
20+
```text
21+
CPU
22+
100% ┤ ┌──┐ ┌─┐ ┌──┐ ┌─┐ ┌──┐ ┌─┐ ┌──┐
23+
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │
24+
50% ┼─┼──┼───┼─┼──┼──┼──┼─┼───┼──┼──┼─┼──┼──┼── mean = 50%
25+
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │
26+
0% ┴─┘ └───┘ └──┘ └──┘ └───┘ └──┘ └──┘ └──▶ time
27+
cpu sleep cpu sleep ... (each half sums to 50%)
28+
```

scenarios/python_spiky_3.11/expected_profile.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@
2121
"stack-content": [
2222
{
2323
"regular_expression": ".*cpu_spike",
24-
"percent": 90,
25-
"error_margin": 10
24+
"percent": 99,
25+
"error_margin": 5
26+
},
27+
{
28+
"regular_expression": ".*sleep_period",
29+
"percent": 0,
30+
"error_margin": 5
2631
}
2732
]
2833
}

0 commit comments

Comments
 (0)