Skip to content
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

Add DTRACE points to measure request timings. #11245

Merged
merged 18 commits into from
Mar 20, 2020
Merged
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
Prev Previous commit
Next Next commit
Add example files for bpftrace.
  • Loading branch information
neunhoef committed Mar 5, 2020
commit d088e52019b84decf6795f3a7e8dd94e7668ac55
135 changes: 135 additions & 0 deletions scripts/measureRequestLife.bt
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/env bpftrace

BEGIN {
@START = nsecs;
@ProcessRequest = 0;
@ProcessStream = 0;
@ProcessMessage = 0;
printf("Measuring timings for requests in arangod...\n");
printf("Values are (in this order per line):\n");
printf(" Absolute time since script start (all times in nanoseconds)\n");
printf(" CommTask::processRequest -> CommTask::prepareExecution\n");
printf(" CommTask::prepareExecution -> CommTask::executeRequest\n");
printf(" CommTask::executeRequest -> CommTask::handleRequestSync\n");
printf(" CommTask::handleRequestSync -> RestHandler::executeEngine\n");
printf(" RestHandler::executeEngine -> CommTask::sendResponse\n");
printf(" CommTask::sendResponse -> CommTask::writeResponse\n");
printf(" CommTask::writeResponse -> CommTask::responseWritten\n");
printf(" Total time for request until response written\n");
}

usdt:build/bin/arangod:arangod:HttpCommTaskProcess* {
@ProcessRequest = nsecs;
}

usdt:build/bin/arangod:arangod:CommTaskPrepareExecution {
@PrepareExecution = nsecs;
}

usdt:build/bin/arangod:arangod:CommTaskExecuteRequest {
@ExecuteRequest = nsecs;
}

usdt:build/bin/arangod:arangod:CommTaskHandleRequestSync {
@HandleRequestSync = nsecs;
}

usdt:build/bin/arangod:arangod:RestHandlerExecuteEngine {
@ExecuteEngine = nsecs;
}

usdt:build/bin/arangod:arangod:HttpCommTaskSendResponse* {
@SendResponse = nsecs;
}

usdt:build/bin/arangod:arangod:HttpCommTaskWriteResponse* {
@WriteResponse = nsecs;
}

usdt:build/bin/arangod:arangod:HttpCommTaskResponseWritten* {
$t = nsecs;
if (@ProcessRequest != 0) {
printf("%lld %lld %lld %lld %lld %lld ",
$t - @START,
@PrepareExecution - @ProcessRequest,
@ExecuteRequest - @PrepareExecution,
@HandleRequestSync - @ExecuteRequest,
@ExecuteEngine - @HandleRequestSync,
@SendResponse - @ExecuteEngine);
printf("%lld %lld %lld\n",
@WriteResponse - @SendResponse,
$t - @WriteResponse,
$t - @ProcessRequest);
@Total = hist($t - @ProcessRequest);
} else {
printf("%lld ResponseWritten\n", $t - @START);
}
@ProcessRequest = 0;
}

usdt:build/bin/arangod:arangod:H2CommTaskProcessStream* {
@ProcessStream = nsecs;
}

usdt:build/bin/arangod:arangod:H2CommTaskSendResponse* {
@SendResponse = nsecs;
}

usdt:build/bin/arangod:arangod:H2CommTaskBeforeAsyncWrite* {
@BeforeAsyncWrite = nsecs;
}

usdt:build/bin/arangod:arangod:H2CommTaskAfterAsyncWrite* {
$t = nsecs;
if (@ProcessStream != 0) {
printf("%lld %lld %lld %lld %lld %lld ",
$t - @START,
@PrepareExecution - @ProcessStream,
@ExecuteRequest - @PrepareExecution,
@HandleRequestSync - @ExecuteRequest,
@ExecuteEngine - @HandleRequestSync,
@SendResponse - @ExecuteEngine);
printf("%lld %lld %lld\n",
@BeforeAsyncWrite - @SendResponse,
$t - @BeforeAsyncWrite,
$t - @ProcessStream);
@Total = hist($t - @ProcessStream);
} else {
printf("%lld AfterAsyncWrite\n", $t - @START);
}
@ProcessStream = 0;
}

usdt:build/bin/arangod:arangod:VstCommTaskProcessMessage* {
@ProcessMessage = nsecs;
}

usdt:build/bin/arangod:arangod:VstCommTaskSendResponse* {
@SendResponse = nsecs;
}

usdt:build/bin/arangod:arangod:VstCommTaskBeforeAsyncWrite* {
@BeforeAsyncWrite = nsecs;
}

usdt:build/bin/arangod:arangod:VstCommTaskAfterAsyncWrite* {
$t = nsecs;
if (@ProcessMessage != 0) {
printf("%lld %lld %lld %lld %lld %lld ",
$t - @START,
@PrepareExecution - @ProcessMessage,
@ExecuteRequest - @PrepareExecution,
@HandleRequestSync - @ExecuteRequest,
@ExecuteEngine - @HandleRequestSync,
@SendResponse - @ExecuteEngine);
printf("%lld %lld %lld\n",
@BeforeAsyncWrite - @SendResponse,
$t - @BeforeAsyncWrite,
$t - @ProcessMessage);
@Total = hist($t - @ProcessMessage);
} else {
printf("%lld AfterAsyncWrite\n", $t - @START);
}
@ProcessMessage = 0;
}

87 changes: 87 additions & 0 deletions scripts/showRequestLife.bt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env bpftrace

BEGIN {
@START = nsecs;
printf("Tracing timings for requests in arangod...\n");
}

usdt:build/bin/arangod:arangod:HttpCommTaskProcess* {
printf("%llu HttpCommTask::processRequest this=%llx\n", (nsecs-@START)/1000,
arg0);
}

usdt:build/bin/arangod:arangod:CommTaskPrepareExecution {
printf("%llu CommTask::prepareExecution this=%llx\n", (nsecs-@START)/1000,
arg0);
}

usdt:build/bin/arangod:arangod:CommTaskExecuteRequest {
printf("%llu CommTask::executeRequest this=%llx\n", (nsecs-@START)/1000,
arg0);
}

usdt:build/bin/arangod:arangod:CommTaskHandleRequestSync {
printf("%llu CommTask::handleRequestSync commtask=%llx handler=%llx\n",
(nsecs-@START)/1000, arg0, arg1);
}

usdt:build/bin/arangod:arangod:RestHandlerExecuteEngine {
printf("%llu RestHandler::executeEngine this=%llx\n", (nsecs-@START)/1000,
arg0);
}

usdt:build/bin/arangod:arangod:HttpCommTaskSendResponse* {
printf("%llu HttpCommTask::sendResponse this=%llx\n",
(nsecs-@START)/1000, arg0);
}

usdt:build/bin/arangod:arangod:HttpCommTaskWriteResponse* {
printf("%llu HttpCommTask::writeResponse this=%llx\n",
(nsecs-@START)/1000, arg0);
}

usdt:build/bin/arangod:arangod:HttpCommTaskResponseWritten* {
printf("%llu HttpCommTask::ResponseWritten this=%llx\n",
(nsecs-@START)/1000, arg0);
}

usdt:build/bin/arangod:arangod:H2CommTaskProcessStream* {
printf("%llu H2CommTask::processStream this=%llx\n", (nsecs-@START)/1000,
arg0);
}

usdt:build/bin/arangod:arangod:H2CommTaskSendResponse* {
printf("%llu H2CommTask::sendResponse this=%llx\n",
(nsecs-@START)/1000, arg0);
}

usdt:build/bin/arangod:arangod:H2CommTaskBeforeAsyncWrite* {
printf("%llu H2CommTask::BeforeAsyncWrite this=%llx\n",
(nsecs-@START)/1000, arg0);
}

usdt:build/bin/arangod:arangod:H2CommTaskAfterAsyncWrite* {
printf("%llu H2CommTask::AfterAsyncWritten this=%llx\n",
(nsecs-@START)/1000, arg0);
}

usdt:build/bin/arangod:arangod:VstCommTaskProcess* {
printf("%llu VstCommTask::processMessage this=%llx\n", (nsecs-@START)/1000,
arg0);
}

usdt:build/bin/arangod:arangod:VstCommTaskSendResponse* {
printf("%llu H2CommTask::sendResponse this=%llx\n",
(nsecs-@START)/1000, arg0);
}

usdt:build/bin/arangod:arangod:VstCommTaskBeforeAsyncWrite* {
printf("%llu VstCommTask::BeforeAsyncWrite this=%llx\n",
(nsecs-@START)/1000, arg0);
}

usdt:build/bin/arangod:arangod:VstCommTaskAfterAsyncWrite* {
printf("%llu VstCommTask::AfterAsyncWritten this=%llx\n",
(nsecs-@START)/1000, arg0);
}