Skip to content

Instantly share code, notes, and snippets.

@135e2
Created December 4, 2023 11:39
Show Gist options
  • Select an option

  • Save 135e2/5477e907351e299c83da1676ad6b2821 to your computer and use it in GitHub Desktop.

Select an option

Save 135e2/5477e907351e299c83da1676ad6b2821 to your computer and use it in GitHub Desktop.
SEU-Mirrors: Testing Scripts
#!/usr/bin/env bpftrace
BEGIN
{
printf("Tracing open file latency... Hit Ctrl-C to end.\n");
}
tracepoint:syscalls:sys_enter_openat
{
if (strncmp(str(args->filename), "/opt/tunasync/serve/archlinux", 29) == 0) {
printf("%s ", str(args->filename));
@start[tid] = nsecs;
}
}
tracepoint:syscalls:sys_exit_sendfile64
/@start[tid]/
{
$delta = (nsecs - @start[tid]) / 1000;
printf("(%d bytes): %d ms\n", args->ret, $delta / 1000);
@usec = hist($delta);
@usec_stats = stats($delta);
delete(@start[tid]);
}
END
{
clear(@start);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment