-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
profiler: randomize when execution traces are collected
We currently record execution traces at a fixed interval. This means that apps which are deployed across several instances simulatenously will have time periods where no instances have execution trace data. This also biases us against activity which occurs with a frequency which is harmonic with the trace collection frequency. To fully address this we would need to decouple execution trace collection from the normal profiling cycle. But as a first step, we should give every profiling cycle a chance of recording data. This commit does that: each profiling cycle we record an execution trace with probability (profiling period) / (trace period). This way we still maintain the same desired avarage data rate of ~one trace every 15 minutes by default. We have one special case, though: we want a trace for the first profile cycle to capture startup activity, since that's usually quite different than normal program activity. Inline the shouldTrace function into the one place it should actually be used. Prior to this commit, shouldTrace was called from two places: once to decide whether to trace, and once as a double-check right before starting the trace. The double-check is not particularly helpful, and if we're making a decision randomly, then checking twice means we'd have to win the "coin toss" twice to record data. So we inline the logic into a single place, right before scheduling a trace. This is tested by doing many "trials" of recording profiles with different execution trace configurations, seeing how many traces we get, and making assertions about the number we see based on the expected probability of tracing. On the one hand, the actual change is fairly simple so perhaps this level of testing is overkill. We also are deliberatly introducing a "flaky" test. On the other hand, the first draft of this change had a bug from calling shouldTrace twice, and the added test catches that quite consistently. The test could be even stronger but perhaps this is good enough to start.
- Loading branch information
Showing
3 changed files
with
133 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters