Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
src
core
lib
transport
bdp_estimator.h
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2016 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_TRANSPORT_BDP_ESTIMATOR_H
20
#define GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H
21
22
#include <
grpc/support/port_platform.h
>
23
24
#include <inttypes.h>
25
26
#include <
grpc/impl/codegen/gpr_types.h
>
27
#include <
grpc/support/log.h
>
28
#include <
grpc/support/time.h
>
29
30
#include "
src/core/lib/debug/trace.h
"
31
#include "
src/core/lib/gprpp/time.h
"
32
33
extern
grpc_core::TraceFlag
grpc_bdp_estimator_trace
;
34
35
namespace
grpc_core
{
36
37
class
BdpEstimator
{
38
public
:
39
explicit
BdpEstimator
(
const
char
*
name
);
40
~BdpEstimator
() {}
41
42
int64_t
EstimateBdp
()
const
{
return
estimate_
; }
43
double
EstimateBandwidth
()
const
{
return
bw_est_
; }
44
45
void
AddIncomingBytes
(
int64_t
num_bytes) {
accumulator_
+= num_bytes; }
46
47
// Schedule a ping: call in response to receiving a true from
48
// grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a
49
// transport (but not necessarily started)
50
void
SchedulePing
() {
51
if
(
GRPC_TRACE_FLAG_ENABLED
(
grpc_bdp_estimator_trace
)) {
52
gpr_log
(
GPR_INFO
,
"bdp[%s]:sched acc=%"
PRId64
" est=%"
PRId64,
name_
,
53
accumulator_
,
estimate_
);
54
}
55
GPR_ASSERT
(
ping_state_
==
PingState::UNSCHEDULED
);
56
ping_state_
=
PingState::SCHEDULED
;
57
accumulator_
= 0;
58
}
59
60
// Start a ping: call after calling grpc_bdp_estimator_schedule_ping and
61
// once
62
// the ping is on the wire
63
void
StartPing
() {
64
if
(
GRPC_TRACE_FLAG_ENABLED
(
grpc_bdp_estimator_trace
)) {
65
gpr_log
(
GPR_INFO
,
"bdp[%s]:start acc=%"
PRId64
" est=%"
PRId64,
name_
,
66
accumulator_
,
estimate_
);
67
}
68
GPR_ASSERT
(
ping_state_
==
PingState::SCHEDULED
);
69
ping_state_
=
PingState::STARTED
;
70
ping_start_time_
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
71
}
72
73
// Completes a previously started ping, returns when to schedule the next one
74
Timestamp
CompletePing
();
75
76
int64_t
accumulator
() {
return
accumulator_
; }
77
78
private
:
79
enum class
PingState
{
UNSCHEDULED
,
SCHEDULED
,
STARTED
};
80
81
PingState
ping_state_
;
82
int64_t
accumulator_
;
83
int64_t
estimate_
;
84
// when was the current ping started?
85
gpr_timespec
ping_start_time_
;
86
Duration
inter_ping_delay_
;
87
int
stable_estimate_count_
;
88
double
bw_est_
;
89
const
char
*
name_
;
90
};
91
92
}
// namespace grpc_core
93
94
#endif
/* GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H */
trace.h
GPR_INFO
#define GPR_INFO
Definition:
include/grpc/impl/codegen/log.h:56
log.h
grpc_core::BdpEstimator::accumulator
int64_t accumulator()
Definition:
bdp_estimator.h:76
grpc_core::BdpEstimator::PingState::STARTED
@ STARTED
grpc_core::BdpEstimator::PingState
PingState
Definition:
bdp_estimator.h:79
grpc_core
Definition:
call_metric_recorder.h:31
grpc_core::Timestamp
Definition:
src/core/lib/gprpp/time.h:62
grpc_core::BdpEstimator::estimate_
int64_t estimate_
Definition:
bdp_estimator.h:83
grpc_core::BdpEstimator::EstimateBdp
int64_t EstimateBdp() const
Definition:
bdp_estimator.h:42
setup.name
name
Definition:
setup.py:542
time.h
grpc_core::BdpEstimator::name_
const char * name_
Definition:
bdp_estimator.h:89
GRPC_TRACE_FLAG_ENABLED
#define GRPC_TRACE_FLAG_ENABLED(f)
Definition:
debug/trace.h:114
grpc_core::BdpEstimator::ping_start_time_
gpr_timespec ping_start_time_
Definition:
bdp_estimator.h:85
grpc_core::BdpEstimator::PingState::SCHEDULED
@ SCHEDULED
grpc_core::BdpEstimator::BdpEstimator
BdpEstimator(const char *name)
Definition:
bdp_estimator.cc:34
grpc_core::BdpEstimator::EstimateBandwidth
double EstimateBandwidth() const
Definition:
bdp_estimator.h:43
GPR_ASSERT
#define GPR_ASSERT(x)
Definition:
include/grpc/impl/codegen/log.h:94
grpc_core::BdpEstimator::StartPing
void StartPing()
Definition:
bdp_estimator.h:63
int64_t
signed __int64 int64_t
Definition:
stdint-msvc2008.h:89
grpc_core::BdpEstimator::SchedulePing
void SchedulePing()
Definition:
bdp_estimator.h:50
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
time.h
GPR_CLOCK_MONOTONIC
@ GPR_CLOCK_MONOTONIC
Definition:
gpr_types.h:36
grpc_core::BdpEstimator::bw_est_
double bw_est_
Definition:
bdp_estimator.h:88
grpc_core::BdpEstimator::stable_estimate_count_
int stable_estimate_count_
Definition:
bdp_estimator.h:87
gpr_now
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
gpr_types.h
grpc_core::TraceFlag
Definition:
debug/trace.h:63
grpc_core::BdpEstimator::PingState::UNSCHEDULED
@ UNSCHEDULED
grpc_core::BdpEstimator::ping_state_
PingState ping_state_
Definition:
bdp_estimator.h:81
grpc_core::BdpEstimator::accumulator_
int64_t accumulator_
Definition:
bdp_estimator.h:82
grpc_core::BdpEstimator::CompletePing
Timestamp CompletePing()
Definition:
bdp_estimator.cc:44
grpc_core::BdpEstimator::inter_ping_delay_
Duration inter_ping_delay_
Definition:
bdp_estimator.h:86
grpc_bdp_estimator_trace
grpc_core::TraceFlag grpc_bdp_estimator_trace
grpc_core::BdpEstimator::AddIncomingBytes
void AddIncomingBytes(int64_t num_bytes)
Definition:
bdp_estimator.h:45
gpr_timespec
Definition:
gpr_types.h:50
grpc_core::Duration
Definition:
src/core/lib/gprpp/time.h:122
grpc_core::BdpEstimator
Definition:
bdp_estimator.h:37
grpc_core::BdpEstimator::~BdpEstimator
~BdpEstimator()
Definition:
bdp_estimator.h:40
port_platform.h
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:36