buffer_list.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_IOMGR_BUFFER_LIST_H
20 #define GRPC_CORE_LIB_IOMGR_BUFFER_LIST_H
21 
23 
24 #include "absl/types/optional.h"
25 
26 #include <grpc/support/time.h>
27 
32 
33 namespace grpc_core {
34 
36  /* Delivery rate in Bytes/s. */
38  /* If the delivery rate is limited by the application, this is set to true. */
40  /* Total packets retransmitted. */
42  /* Total packets retransmitted spuriously. This metric is smaller than or
43  equal to packet_retx. */
45  /* Total packets sent. */
47  /* Total packets delivered. */
49  /* Total packets delivered with ECE marked. This metric is smaller than or
50  equal to packet_delivered. */
52  /* Total bytes lost so far. */
54  /* Total bytes sent so far. */
56  /* Total bytes in write queue but not sent. */
58  /* Pacing rate of the connection in Bps */
60  /* Minimum RTT observed in usec. */
62  /* Smoothed RTT in usec */
64  /* Send congestion window. */
66  /* Slow start threshold in packets. */
68  /* Maximum degree of reordering (i.e., maximum number of packets reodered)
69  on the connection. */
71  /* Represents the number of recurring retransmissions of the first sequence
72  that is not acknowledged yet. */
74  /* The cumulative time (in usec) that the transport protocol was busy
75  sending data. */
77  /* The cumulative time (in usec) that the transport protocol was limited by
78  the receive window size. */
80  /* The cumulative time (in usec) that the transport protocol was limited by
81  the send buffer size. */
83 };
84 
87  ConnectionMetrics metrics; /* Metrics collected with this timestamp */
88 };
89 
90 struct Timestamps {
95 
96  uint32_t byte_offset; /* byte offset relative to the start of the RPC */
97 
98 #ifdef GRPC_LINUX_ERRQUEUE
99  tcp_info info; /* tcp_info collected on sendmsg */
100 #endif /* GRPC_LINUX_ERRQUEUE */
101 };
102 
114 #ifdef GRPC_LINUX_ERRQUEUE
115 class TracedBuffer {
116  public:
118  TracedBuffer(uint32_t seq_no, void* arg)
119  : seq_no_(seq_no), arg_(arg), next_(nullptr) {}
120 
123  static void AddNewEntry(TracedBuffer** head, uint32_t seq_no, int fd,
124  void* arg);
125 
129  static void ProcessTimestamp(TracedBuffer** head,
130  struct sock_extended_err* serr,
131  struct cmsghdr* opt_stats,
132  struct scm_timestamping* tss);
133 
136  static void Shutdown(TracedBuffer** head, void* remaining,
137  grpc_error_handle shutdown_err);
138 
139  private:
140  uint32_t seq_no_; /* The sequence number for the last byte in the buffer */
141  void* arg_; /* The arg to pass to timestamps_callback */
142  Timestamps ts_; /* The timestamps corresponding to this buffer */
143  TracedBuffer* next_; /* The next TracedBuffer in the list */
144 };
145 #else /* GRPC_LINUX_ERRQUEUE */
147  public:
148  /* Phony shutdown function */
149  static void Shutdown(TracedBuffer** /*head*/, void* /*remaining*/,
150  grpc_error_handle shutdown_err) {
151  GRPC_ERROR_UNREF(shutdown_err);
152  }
153 };
154 #endif /* GRPC_LINUX_ERRQUEUE */
155 
159  void (*fn)(void*, Timestamps*, grpc_error_handle error));
160 
161 } /* namespace grpc_core */
162 
163 #endif /* GRPC_CORE_LIB_IOMGR_BUFFER_LIST_H */
grpc_core::BufferTimestamp
Definition: buffer_list.h:85
grpc_core::ConnectionMetrics::delivery_rate
absl::optional< uint64_t > delivery_rate
Definition: buffer_list.h:37
grpc_core::ConnectionMetrics
Definition: buffer_list.h:35
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::ConnectionMetrics::congestion_window
absl::optional< uint32_t > congestion_window
Definition: buffer_list.h:65
error
grpc_error_handle error
Definition: retry_filter.cc:499
grpc_core::grpc_tcp_set_write_timestamps_callback
void grpc_tcp_set_write_timestamps_callback(void(*fn)(void *, Timestamps *, grpc_error_handle error))
Definition: buffer_list.cc:297
grpc_core::ConnectionMetrics::data_retx
absl::optional< uint64_t > data_retx
Definition: buffer_list.h:53
internal_errqueue.h
time.h
grpc_core::Timestamps
Definition: buffer_list.h:90
grpc_core::BufferTimestamp::time
gpr_timespec time
Definition: buffer_list.h:86
memory.h
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
grpc_core::ConnectionMetrics::reordering
absl::optional< uint32_t > reordering
Definition: buffer_list.h:70
grpc_core::Timestamps::sent_time
BufferTimestamp sent_time
Definition: buffer_list.h:93
grpc_core::Timestamps::sendmsg_time
BufferTimestamp sendmsg_time
Definition: buffer_list.h:91
grpc_core::Timestamps::acked_time
BufferTimestamp acked_time
Definition: buffer_list.h:94
grpc_core::ConnectionMetrics::data_sent
absl::optional< uint64_t > data_sent
Definition: buffer_list.h:55
generate-asm-lcov.fn
fn
Definition: generate-asm-lcov.py:146
grpc_core::BufferTimestamp::metrics
ConnectionMetrics metrics
Definition: buffer_list.h:87
absl::optional< uint64_t >
grpc_core::ConnectionMetrics::packet_delivered
absl::optional< uint32_t > packet_delivered
Definition: buffer_list.h:48
arg
Definition: cmdline.cc:40
error.h
grpc_core::ConnectionMetrics::recurring_retrans
absl::optional< uint8_t > recurring_retrans
Definition: buffer_list.h:73
grpc_core::ConnectionMetrics::srtt
absl::optional< uint32_t > srtt
Definition: buffer_list.h:63
grpc_core::TracedBuffer::Shutdown
static void Shutdown(TracedBuffer **, void *, grpc_error_handle shutdown_err)
Definition: buffer_list.h:149
grpc_core::ConnectionMetrics::packet_sent
absl::optional< uint32_t > packet_sent
Definition: buffer_list.h:46
port.h
grpc_core::Timestamps::byte_offset
uint32_t byte_offset
Definition: buffer_list.h:96
grpc_core::TracedBuffer
Definition: buffer_list.h:146
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition: error.h:262
grpc_core::ConnectionMetrics::packet_delivered_ce
absl::optional< uint32_t > packet_delivered_ce
Definition: buffer_list.h:51
grpc_core::Timestamps::scheduled_time
BufferTimestamp scheduled_time
Definition: buffer_list.h:92
grpc_core::ConnectionMetrics::busy_usec
absl::optional< uint64_t > busy_usec
Definition: buffer_list.h:76
grpc_core::ConnectionMetrics::sndbuf_limited_usec
absl::optional< uint64_t > sndbuf_limited_usec
Definition: buffer_list.h:82
grpc_core::ConnectionMetrics::rwnd_limited_usec
absl::optional< uint64_t > rwnd_limited_usec
Definition: buffer_list.h:79
grpc_core::ConnectionMetrics::min_rtt
absl::optional< uint32_t > min_rtt
Definition: buffer_list.h:61
gpr_timespec
Definition: gpr_types.h:50
grpc_core::ConnectionMetrics::data_notsent
absl::optional< uint64_t > data_notsent
Definition: buffer_list.h:57
grpc_error
Definition: error_internal.h:42
grpc_core::ConnectionMetrics::snd_ssthresh
absl::optional< uint32_t > snd_ssthresh
Definition: buffer_list.h:67
grpc_core::ConnectionMetrics::pacing_rate
absl::optional< uint64_t > pacing_rate
Definition: buffer_list.h:59
grpc_core::ConnectionMetrics::packet_retx
absl::optional< uint32_t > packet_retx
Definition: buffer_list.h:41
grpc_core::ConnectionMetrics::is_delivery_rate_app_limited
absl::optional< bool > is_delivery_rate_app_limited
Definition: buffer_list.h:39
grpc_core::ConnectionMetrics::packet_spurious_retx
absl::optional< uint32_t > packet_spurious_retx
Definition: buffer_list.h:44
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:41