| Code-Review | +1 |
Example usage:Cool stuff. Consider finding a place for this documentation in `runtime/docs/...` (either find an existing file this fits or add one).
#if defined(DART_HOST_OS_LINUX)I think this belongs into `os_linux.cc`.
#if defined(DART_HOST_OS_LINUX)Move this chunk of code into `OS::Notify{Before,After}GC`
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Cool stuff. Consider finding a place for this documentation in `runtime/docs/...` (either find an existing file this fits or add one).
Done
I think this belongs into `os_linux.cc`.
Done
Move this chunk of code into `OS::Notify{Before,After}GC`
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
`perf stat` supports starting and stopping the recording via `--control`Empty line after `##`
(You might also consider formatting Markdown using e.g. go/mdformat - it makes it easier to read as plain text).
void OS::NotifyBeforeGC() {}empty line before the definition.
void PerfCtrlDisable() {static or anonymous namespace (the same applies to the function below).
https://google.github.io/styleguide/cppguide.html#Internal_Linkage
void OS::NotifyBeforeGC() {}add empty line before the definition.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Needs `TEST=manually` to be able to land the CL.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Needs `TEST=manually` to be able to land the CL.
Done
`perf stat` supports starting and stopping the recording via `--control`Empty line after `##`
(You might also consider formatting Markdown using e.g. go/mdformat - it makes it easier to read as plain text).
Done
empty line before the definition.
Done
static or anonymous namespace (the same applies to the function below).
https://google.github.io/styleguide/cppguide.html#Internal_Linkage
Done
add empty line before the definition.
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
3 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: runtime/vm/os_fuchsia.cc
Insertions: 1, Deletions: 0.
@@ -507,6 +507,7 @@
void OS::DebugBreak() {
UNIMPLEMENTED();
}
+
void OS::NotifyBeforeGC() {}
void OS::NotifyAfterGC() {}
```
```
The name of the file: runtime/docs/perf.md
Insertions: 13, Deletions: 9.
@@ -1,12 +1,16 @@
# Dart support for perf
## Pause `perf stat` recording while GC is running (or vice versa)
-`perf stat` supports starting and stopping the recording via `--control`
-and the Dart VM can be instructed to either stop the recording while
-GC is running, or specifically start while GC is running (and stop when GC is finished)
-with `--perf_ctl_fd`, `--perf_ctl_fd_ack` (for file handles) and `--perf_ctl_usage` (1 or 2) to specify if it should be paused while GCing (1) or started (and stoped) while GCing (2).
-These options can for instance be useful for testing performance changes in AOT compiled dart together with `--deterministic`.
+`perf stat` supports starting and stopping the recording via `--control` and the
+Dart VM can be instructed to either stop the recording while GC is running, or
+specifically start while GC is running (and stop when GC is finished) with
+`--perf_ctl_fd`, `--perf_ctl_fd_ack` (for file handles) and `--perf_ctl_usage`
+(1 or 2) to specify if it should be paused while GCing (1) or started (and
+stoped) while GCing (2).
+
+These options can for instance be useful for testing performance changes in AOT
+compiled dart together with `--deterministic`.
As an example one could run a script like this:
@@ -25,7 +29,7 @@
(the missing pieces can be found in the perf stat man page).
-This will start `perf stat` paused (which would require the run dart aot-compiled script to start it when it wants to) and where the VM pauses `perf` while doing GC.
-Note that the recording will be started when GC is done, even if it wasn't started before.
-
-
+This will start `perf stat` paused (which would require the run dart
+aot-compiled script to start it when it wants to) and where the VM pauses `perf`
+while doing GC. Note that the recording will be started when GC is done, even if
+it wasn't started before.
```
```
The name of the file: runtime/vm/os_linux.cc
Insertions: 2, Deletions: 0.
@@ -593,6 +593,7 @@
__builtin_trap();
}
+namespace {
void PerfCtrlDisable() {
if (FLAG_perf_ctl_fd > 0 && FLAG_perf_ctl_fd_ack > 0) {
write(FLAG_perf_ctl_fd, "disable", 7);
@@ -610,6 +611,7 @@
read(FLAG_perf_ctl_fd_ack, ack, 5);
}
}
+} // namespace
void OS::NotifyBeforeGC() {
if (FLAG_perf_ctl_usage == 1) {
```
```
The name of the file: runtime/vm/os_win.cc
Insertions: 1, Deletions: 0.
@@ -280,6 +280,7 @@
}
#endif
}
+
void OS::NotifyBeforeGC() {}
void OS::NotifyAfterGC() {}
```
```
The name of the file: runtime/vm/os_macos.cc
Insertions: 1, Deletions: 0.
@@ -167,6 +167,7 @@
void OS::DebugBreak() {
__builtin_trap();
}
+
void OS::NotifyBeforeGC() {}
void OS::NotifyAfterGC() {}
```
[vm] Allow Before/After GC to signal `perf`
This CL makes it possible for the Dart VM to start or stop `perf` while
doing GC, which gives a significantly more stable output.
Example usage:
Bash script that creates the correct file handles and calls dart under
`perf stat` based on the arguments given to the script:
```
DART=$1
shift
AOTSNAPSHOT=$1
shift
ctl_dir=/tmp/
ctl_fifo=${ctl_dir}perf_ctl.fifo
test -p ${ctl_fifo} && unlink ${ctl_fifo}
mkfifo ${ctl_fifo}
exec {ctl_fd}<>${ctl_fifo}
ctl_ack_fifo=${ctl_dir}perf_ctl_ack.fifo
test -p ${ctl_ack_fifo} && unlink ${ctl_ack_fifo}
mkfifo ${ctl_ack_fifo}
exec {ctl_fd_ack}<>${ctl_ack_fifo}
perf_ctl_fd=$ctl_fd perf_ctl_fd_ack=$ctl_fd_ack perf stat --delay=-1 --control fd:${ctl_fd},${ctl_fd_ack} -B -e "task-clock:u,context-switches:u,cpu-migrations:u,page-faults:u,cycles:u,instructions:u,branch-misses:u" $DART --perf_ctl_fd=${ctl_fd} --perf_ctl_fd_ack=${ctl_fd_ack} --perf_ctl_usage=1 --deterministic $AOTSNAPSHOT $@
exec {ctl_fd_ack}>&-
unlink ${ctl_ack_fifo}
exec {ctl_fd}>&-
unlink ${ctl_fifo}
```
This will start `perf stat` paused (which would require the run dart
aot-compiled script to start it when it wants to) and where the VM
pauses `perf` while doing GC.
In practise, looking at instruction counts reported by `perf stat`, I've
seen the difference between runs go from 2+ mio (and in some instances
23+ mio) to around 30,000 (!) on runs of the analyzer (tool
"stable_analysis").
TEST=manually
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
significantly more stable output.
--deterministic
You may want to also use --marker_tasks=1.
The --deterministic flag was added with the goal of making snapshot output deterministic. It disables concurrent marking and sweeping to avoid affecting what is seen by full walks of the heap. But it does not disable parallel marking because that doesn't affect which objects survive a given GC cycle and so doesn't affect snapshot output, though it will affect perf determinism as the workers race to handle the marking worklists.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
significantly more stable output.
--deterministicYou may want to also use --marker_tasks=1.
The --deterministic flag was added with the goal of making snapshot output deterministic. It disables concurrent marking and sweeping to avoid affecting what is seen by full walks of the heap. But it does not disable parallel marking because that doesn't affect which objects survive a given GC cycle and so doesn't affect snapshot output, though it will affect perf determinism as the workers race to handle the marking worklists.
Interesting, thanks!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |