kevin-wu24 commented on code in PR #22669:
URL: https://github.com/apache/kafka/pull/22669#discussion_r3485016183


##########
raft/src/testFixtures/java/org/apache/kafka/raft/RaftClientBenchmarkContext.java:
##########
@@ -176,7 +219,21 @@ public int drainQuorumStateWrites() {
         return delta;
     }
 
-    public int drainRpcResponsesSent() {
-        return context.drainAllSentResponses();
+    public int drainQuorumStateReads() {
+        int current = context.quorumStateReadCount();
+        int delta = current - lastQuorumReads;
+        lastQuorumReads = current;
+        return delta;
+    }
+
+    /**
+     * Number of responses sent since the last drain. If {@code apiKey} is 
present, only responses of
+     * that API key are counted; otherwise all responses are counted.
+     */
+    public int drainRpcResponsesSent(Optional<ApiKeys> apiKey) {
+        if (apiKey.isEmpty()) {
+            return context.drainAllSentResponses();
+        }

Review Comment:
   If a benchmarked code has outstanding sent responses before calling this 
method, the benchmark writer should know what those are. What do you think 
about renaming this method to `maybeDrainSentRpcResponses(Optional<ApiKeys> 
apiKey)` and the below implementation:
   
   ```
   if apiKey is present, 
       drain for the specific api key supplied (try to use the existing helpers 
again here) and store that number
   assert the sentResponses queue is empty
   return the stored number or 0
   ```
   
   The motivation for this implementation is similar to what is proposed for 
properly draining + collecting deltas on the send queue.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to