Skip to content

Commit

Permalink
add writeThreadQueuedLatency (apache#3363)
Browse files Browse the repository at this point in the history
add writeThreadQueueStats :  calculate the time the request stays in the write threadpool queue

(cherry picked from commit 79808dc)
  • Loading branch information
lordcheng10 authored and hangc0276 committed Nov 7, 2022
1 parent cbaf9f8 commit c85d0f6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public interface BookKeeperServerStats {
// Stats
String ADD_ENTRY_REQUEST = "ADD_ENTRY_REQUEST";
String ADD_ENTRY = "ADD_ENTRY";
String WRITE_THREAD_QUEUED_LATENCY = "WRITE_THREAD_QUEUED_LATENCY";
String FORCE_LEDGER_REQUEST = "FORCE_LEDGER_REQUEST";
String FORCE_LEDGER = "FORCE_LEDGER";
String READ_ENTRY_REQUEST = "READ_ENTRY_REQUEST";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ protected void sendResponseAndWait(int rc, Object response, OpStatsLogger statsL

@Override
public void safeRun() {
requestProcessor.getRequestStats().getWriteThreadQueuedLatency()
.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS);
if (!isVersionCompatible()) {
sendResponse(BookieProtocol.EBADVERSION,
ResponseBuilder.buildErrorResponse(BookieProtocol.EBADVERSION, request),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.SERVER_SCOPE;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.WRITE_LAC;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.WRITE_LAC_REQUEST;
import static org.apache.bookkeeper.bookie.BookKeeperServerStats.WRITE_THREAD_QUEUED_LATENCY;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -90,6 +91,14 @@ public class RequestStats {
parent = ADD_ENTRY_REQUEST
)
private final OpStatsLogger addEntryStats;

@StatsDoc(
name = WRITE_THREAD_QUEUED_LATENCY,
help = "operation stats of enqueuing requests to write threadpool queue",
parent = ADD_ENTRY_REQUEST
)
private final OpStatsLogger writeThreadQueuedLatency;

@StatsDoc(
name = READ_ENTRY_REQUEST,
help = "request stats of ReadEntry on a bookie"
Expand Down Expand Up @@ -226,6 +235,7 @@ public class RequestStats {

public RequestStats(StatsLogger statsLogger) {
this.addEntryStats = statsLogger.getOpStatsLogger(ADD_ENTRY);
this.writeThreadQueuedLatency = statsLogger.getOpStatsLogger(WRITE_THREAD_QUEUED_LATENCY);
this.addRequestStats = statsLogger.getOpStatsLogger(ADD_ENTRY_REQUEST);
this.readEntryStats = statsLogger.getOpStatsLogger(READ_ENTRY);
this.forceLedgerStats = statsLogger.getOpStatsLogger(FORCE_LEDGER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ public void writeComplete(int rc, long ledgerId, long entryId,

@Override
public void safeRun() {
requestProcessor.getRequestStats().getWriteThreadQueuedLatency()
.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS);
AddResponse addResponse = getAddResponse();
if (null != addResponse) {
// This means there was an error and we should send this back.
Expand Down

0 comments on commit c85d0f6

Please sign in to comment.