Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions samples/disk-io-blocking-vfs.sxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env stap++

# Measure the distribution of the VFS read/write latency.

global begin, stats, latency, found

probe vfs.read*, vfs.write*
{
if (sprintf("%d", pid()) =~ "^($^target)$") {
begin[pid()] = gettimeofday_ms()
found = 1
}
}

probe vfs.read*.return, vfs.write*.return
{
if (sprintf("%d", pid()) =~ "^($^target)$" && begin[pid()] > 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slow: see how we do this in the ngx-req-distr tool.

latency = gettimeofday_ms() - begin[pid()]
stats[pid()] <<< latency
}
}

probe timer.s($^arg_time :default(5)) {
exit()
}

probe end {

if (found != 1) {
printf("No samples observed so far.\n");

} else {
printf("Distribution of disk read/write blocking latencies (in milliseconds)\n")

foreach (name in stats) {
printf("pid %d:\n", name)
printf("max/avg/min: %d/%d/%d\n", @max(stats[name]), @avg(stats[name]), @min(stats[name]))
print(@hist_log(stats[name]))
}
}
}

probe begin {
printf("Start tracing %d ($^exec_path)...\nPlease wait for %d seconds.\n\n",
target(), $^arg_time)
}
2 changes: 1 addition & 1 deletion stap++
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ if (defined $master_pid) {
}

$StdVars{pid_ok} = gen_pid_test_condition(\@pids);
$StdVars{target} = "@pids";
$StdVars{target} = join "|", @pids;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we don't want this change.


my $pid = $pids[0];
process_dso($pid);
Expand Down