Skip to content

Commit 9381394

Browse files
committed
feat(profilin): Add explanation for lockstep sampling
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 66af8c8 commit 9381394

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,18 @@ 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+
This explanation is an excerpt from [this awesome StackOverflow answer](https://stackoverflow.com/a/45471031/1181370)
307+
which has more details and a nice analogy for the issue.
308+
</Alert>
309+
298310
`samples`
299311

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

0 commit comments

Comments
 (0)