Skip to content

Commit 10cd1e7

Browse files
authored
feat(profilin): Add explanation for lockstep sampling (#11885)
We had this odd sampling frequency value in our docs which looks like a typo but it is not. This PR adds a note box to reassure the readers with some explanation and a reference link to why.
1 parent e2136f9 commit 10cd1e7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

develop-docs/sdk/telemetry/profiles/sample-format-v1.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,21 @@ stack ID.
295295
You should collect samples at a frequency of 101Hz, or roughly once every 10
296296
milliseconds.
297297

298+
<Alert title="Note" level="info">
299+
The 101Hz number above is not a typo. It is intentionally slightly off from 100Hz to avoid a condition
300+
named "lockstep sampling" where the profiling samples occur at the same frequency as a loop in the
301+
application. Ideally, the samples should be much more frequent than any cycles in the application, or
302+
at random intervals, so that the chance it occurs in any particular operation is proportional to the
303+
amount of time that operation takes. But this is often not feasible, so the next best thing is to use
304+
a sampling rate that doesn't coincide with the likely frequency of program cycles.
305+
306+
We also chose 101 for its primality, whereas 1 below 100–99–is evenly divisible by several
307+
smaller numbers, which could lead to similar lockstep behavior.
308+
309+
This explanation is an excerpt from [this awesome StackOverflow answer](https://stackoverflow.com/a/45471031/1181370)
310+
which has more details and a nice analogy for the issue.
311+
</Alert>
312+
298313
`samples`
299314

300315
: *List, required* Contains a list of sample object captured during execution.

0 commit comments

Comments
 (0)