-
Notifications
You must be signed in to change notification settings - Fork 167
feat(prof): improve time sample accuracy by gathering during allocation samples #3559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
f14deb8
5d9030b
989876d
c0119e9
f43a597
243d028
a9c822e
5ee032d
5d79ecd
aa62d66
b1765c0
8b15661
23c9bc1
7e93679
f52cf55
3a7430e
ee910ea
e16e1b1
a3e3e4e
1d40054
eb10ef8
73c86a0
520c158
35ac0b6
87a52f4
093ce66
d2d11b1
78d9cbc
b64dd9a
44e2734
d063129
ea6bc22
ddb1dfc
5114acd
9cb6ba1
1e42042
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
realFlowControl marked this conversation as resolved.
Show resolved
Hide resolved
|
morrisonlevi marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| { | ||
| "args": { | ||
| "DD_PROFILING_ENABLED": "yes", | ||
| "DD_PROFILING_ALLOCATION_ENABLED": "yes", | ||
| "DD_PROFILING_WALL_TIME_ENABLED": "yes", | ||
| "DD_PROFILING_EXPERIMENTAL_CPU_TIME_ENABLED": "no", | ||
| "DD_PROFILING_ENDPOINT_COLLECTION_ENABLED": "no", | ||
| "DD_PROFILING_LOG_LEVEL": "debug", | ||
| "EXECUTION_TIME": "5" | ||
| }, | ||
| "flaky": false, | ||
| "skip-asan": false, | ||
| "todo": "", | ||
| "checks": [ | ||
| { | ||
| "type": "regex", | ||
| "path": "$.sample_types[?(@.type=='samples')].unit", | ||
| "match": "^count$" | ||
| }, | ||
| { | ||
| "type": "regex", | ||
| "path": "$.sample_types[?(@.type=='wall-time')].unit", | ||
| "match": "^nanoseconds$" | ||
| }, | ||
| { | ||
| "type": "regex", | ||
| "path": "$.sample_types[?(@.type=='alloc-samples')].unit", | ||
| "match": "^count$" | ||
| }, | ||
| { | ||
| "type": "regex", | ||
| "path": "$.sample_types[?(@.type=='alloc-space')].unit", | ||
| "match": "^bytes$" | ||
| }, | ||
| { | ||
| "comment": "Verify we have samples with both allocation and time data (piggybacked samples)", | ||
| "type": "jq-minimum", | ||
| "path": ". as $root | (.sample_types | to_entries | map({(.value.type): .key}) | add) as $indices | .samples | map(select(.values[$indices.samples] > 0 and .values[$indices.\"wall-time\"] > 0 and .values[$indices.\"alloc-samples\"] > 0 and .values[$indices.\"alloc-space\"] > 0)) | length", | ||
| "match": 1 | ||
| }, | ||
| { | ||
| "comment": "Verify main function appears in the profile", | ||
| "type": "jq-minimum", | ||
| "path": ".samples | map(select(.location_ids | any(.frames[] | .function // \"\" | contains(\"main\")))) | length", | ||
| "match": 1 | ||
| }, | ||
| { | ||
| "comment": "Verify str_repeat appears in the profile", | ||
| "type": "jq-minimum", | ||
| "path": ".samples | map(select(.location_ids | any(.frames[] | .function // \"\" | contains(\"str_repeat\")))) | length", | ||
| "match": 1 | ||
| }, | ||
| { | ||
| "comment": "Verify we have piggybacked samples that include str_repeat in the stack", | ||
| "type": "jq-minimum", | ||
| "path": ". as $root | (.sample_types | to_entries | map({(.value.type): .key}) | add) as $indices | .samples | map(select(.values[$indices.samples] > 0 and .values[$indices.\"wall-time\"] > 0 and .values[$indices.\"alloc-samples\"] > 0 and .values[$indices.\"alloc-space\"] > 0 and (.location_ids | any(.frames[] | .function // \"\" | contains(\"str_repeat\"))))) | length", | ||
| "match": 1 | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
|
|
||
| // Test to verify that allocation and time profiling can coexist and that | ||
| // the piggybacking optimization works (where time samples are taken during | ||
| // allocation samples when interrupt_count > 0). | ||
| // | ||
| // This test uses str_repeat which allocates large amounts of memory, | ||
| // increasing the likelihood of capturing piggybacked samples. | ||
|
|
||
| function main() { | ||
| $duration = $_ENV["EXECUTION_TIME"] ?? 10; | ||
| $end = microtime(true) + $duration; | ||
|
|
||
| while (microtime(true) < $end) { | ||
| // Allocate large strings to trigger allocation sampling | ||
| $s = str_repeat("x", 10_000_000); | ||
| strlen($s); // Use the string to prevent optimization | ||
|
||
| } | ||
| } | ||
|
|
||
| main(); | ||
Uh oh!
There was an error while loading. Please reload this page.