-
Notifications
You must be signed in to change notification settings - Fork 171
test(profiling): add missing prof correctness tests for I/O profiling #3652
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
Open
realFlowControl
wants to merge
2
commits into
florian/macos-io-profiling
Choose a base branch
from
florian/macos-io-profiling-tests
base: florian/macos-io-profiling
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−2
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| { | ||
| "scale_by_duration": true, | ||
| "test_name": "php_io", | ||
| "stacks": [ | ||
| { | ||
| "profile-type": "file-io-write-size", | ||
| "stack-content": [ | ||
| { | ||
| "regular_expression": "<?php;main;big_write;standard\\|file_put_contents$", | ||
| "percent": 66, | ||
| "error_margin": 2 | ||
| }, | ||
| { | ||
| "regular_expression": "<?php;main;small_write;standard\\|file_put_contents$", | ||
| "percent": 33, | ||
| "error_margin": 2 | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "profile-type": "file-io-read-size", | ||
| "stack-content": [ | ||
| { | ||
| "regular_expression": "<?php;main;big_read;standard\\|file_get_contents$", | ||
| "percent": 66, | ||
| "error_margin": 2 | ||
| }, | ||
| { | ||
| "regular_expression": "<?php;main;small_read;standard\\|file_get_contents$", | ||
| "percent": 33, | ||
| "error_margin": 2 | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?php | ||
| // Test I/O profiling correctness. | ||
| // | ||
| // We write and read temporary files in known proportions to verify that | ||
| // file-io-write-size and file-io-read-size samples are captured correctly. | ||
| // | ||
| // Function `big_write` writes 2x more data than `small_write`, so we expect | ||
| // ~67% vs ~33% of file-io-write-size. Similarly for reads. | ||
| // | ||
| // The write functions return the file path so that read functions can reuse | ||
| // the same files without creating their own (which would pollute the write | ||
| // profile). Files are cleaned up in the main loop. | ||
|
|
||
| function big_write() { | ||
| $tmp = tempnam(sys_get_temp_dir(), 'io_test'); | ||
| // Write 2MB | ||
| file_put_contents($tmp, str_repeat('A', 1024 * 1024 * 2)); | ||
| return $tmp; | ||
| } | ||
|
|
||
| function small_write() { | ||
| $tmp = tempnam(sys_get_temp_dir(), 'io_test'); | ||
| // Write 1MB | ||
| file_put_contents($tmp, str_repeat('B', 1024 * 1024)); | ||
| return $tmp; | ||
| } | ||
|
|
||
| function big_read($path) { | ||
| // Read 2MB | ||
| file_get_contents($path, false, null, 0, 1024 * 1024 * 2); | ||
| } | ||
|
|
||
| function small_read($path) { | ||
| // Read 1MB | ||
| file_get_contents($path, false, null, 0, 1024 * 1024); | ||
| } | ||
|
|
||
| function main() { | ||
| $duration = $_ENV["EXECUTION_TIME"] ?? 10; | ||
| $end = microtime(true) + $duration; | ||
| while (microtime(true) < $end) { | ||
| $big = big_write(); | ||
| $small = small_write(); | ||
| big_read($big); | ||
| small_read($small); | ||
| unlink($big); | ||
| unlink($small); | ||
| } | ||
| } | ||
| main(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An error_margin of 10 is pretty high for this deterministic benchmark, isn't it? Any particular reason it isn't tighter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the runs and they all where at "0% error", but if we start adjusting the sampling distance, we might get some errors in the future.
I've tightened the
error_marginto2%. In case we see failures here when adjusting the sampling distance in the future, we can then make a decision of how to handle that.