Add the length of the buffer that is traced

pull/17331/head
Yash Tibrewal 6 years ago
parent 6697496a1d
commit 7cd7ecc941
  1. 3
      src/core/lib/iomgr/buffer_list.cc
  2. 6
      src/core/lib/iomgr/buffer_list.h
  3. 4
      src/core/lib/iomgr/tcp_posix.cc

@ -30,9 +30,10 @@
namespace grpc_core { namespace grpc_core {
void TracedBuffer::AddNewEntry(TracedBuffer** head, uint32_t seq_no, void TracedBuffer::AddNewEntry(TracedBuffer** head, uint32_t seq_no,
void* arg) { uint32_t length, void* arg) {
GPR_DEBUG_ASSERT(head != nullptr); GPR_DEBUG_ASSERT(head != nullptr);
TracedBuffer* new_elem = New<TracedBuffer>(seq_no, arg); TracedBuffer* new_elem = New<TracedBuffer>(seq_no, arg);
new_elem->ts_.length = length;
/* Store the current time as the sendmsg time. */ /* Store the current time as the sendmsg time. */
new_elem->ts_.sendmsg_time = gpr_now(GPR_CLOCK_REALTIME); new_elem->ts_.sendmsg_time = gpr_now(GPR_CLOCK_REALTIME);
if (*head == nullptr) { if (*head == nullptr) {

@ -37,6 +37,8 @@ struct Timestamps {
gpr_timespec scheduled_time; gpr_timespec scheduled_time;
gpr_timespec sent_time; gpr_timespec sent_time;
gpr_timespec acked_time; gpr_timespec acked_time;
uint32_t length; /* The length of the buffer traced */
}; };
/** TracedBuffer is a class to keep track of timestamps for a specific buffer in /** TracedBuffer is a class to keep track of timestamps for a specific buffer in
@ -56,7 +58,7 @@ class TracedBuffer {
/** Add a new entry in the TracedBuffer list pointed to by head. Also saves /** Add a new entry in the TracedBuffer list pointed to by head. Also saves
* sendmsg_time with the current timestamp. */ * sendmsg_time with the current timestamp. */
static void AddNewEntry(grpc_core::TracedBuffer** head, uint32_t seq_no, static void AddNewEntry(grpc_core::TracedBuffer** head, uint32_t seq_no,
void* arg); uint32_t length, void* arg);
/** Processes a received timestamp based on sock_extended_err and /** Processes a received timestamp based on sock_extended_err and
* scm_timestamping structures. It will invoke the timestamps callback if the * scm_timestamping structures. It will invoke the timestamps callback if the
@ -73,7 +75,7 @@ class TracedBuffer {
private: private:
GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_NEW
TracedBuffer(int seq_no, void* arg) TracedBuffer(uint32_t seq_no, void* arg)
: seq_no_(seq_no), arg_(arg), next_(nullptr) {} : seq_no_(seq_no), arg_(arg), next_(nullptr) {}
uint32_t seq_no_; /* The sequence number for the last byte in the buffer */ uint32_t seq_no_; /* The sequence number for the last byte in the buffer */

@ -634,8 +634,8 @@ static bool tcp_write_with_timestamps(grpc_tcp* tcp, struct msghdr* msg,
if (sending_length == static_cast<size_t>(length)) { if (sending_length == static_cast<size_t>(length)) {
gpr_mu_lock(&tcp->tb_mu); gpr_mu_lock(&tcp->tb_mu);
grpc_core::TracedBuffer::AddNewEntry( grpc_core::TracedBuffer::AddNewEntry(
&tcp->tb_head, static_cast<int>(tcp->bytes_counter + length), &tcp->tb_head, static_cast<uint32_t>(tcp->bytes_counter + length),
tcp->outgoing_buffer_arg); static_cast<uint32_t>(length), tcp->outgoing_buffer_arg);
gpr_mu_unlock(&tcp->tb_mu); gpr_mu_unlock(&tcp->tb_mu);
tcp->outgoing_buffer_arg = nullptr; tcp->outgoing_buffer_arg = nullptr;
} }

Loading…
Cancel
Save