mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: proxy: factorize send rate measurement
Implement a new dedicated function increment_send_rate() which can be call anywhere new bytes must be accounted for global total sent.
This commit is contained in:
parent
1bcb695a05
commit
bc0adfa334
@ -30,6 +30,7 @@
|
|||||||
#include <haproxy/proxy-t.h>
|
#include <haproxy/proxy-t.h>
|
||||||
#include <haproxy/server-t.h>
|
#include <haproxy/server-t.h>
|
||||||
#include <haproxy/ticks.h>
|
#include <haproxy/ticks.h>
|
||||||
|
#include <haproxy/thread.h>
|
||||||
|
|
||||||
extern struct proxy *proxies_list;
|
extern struct proxy *proxies_list;
|
||||||
extern struct eb_root used_proxy_id; /* list of proxy IDs in use */
|
extern struct eb_root used_proxy_id; /* list of proxy IDs in use */
|
||||||
@ -235,6 +236,22 @@ static inline int in_proxies_list(struct proxy *list, struct proxy *proxy)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add <bytes> to the global total bytes sent and adjust the send rate. Set
|
||||||
|
* <splice> if this was sent usigin splicing.
|
||||||
|
*/
|
||||||
|
static inline void increment_send_rate(uint64_t bytes, int splice)
|
||||||
|
{
|
||||||
|
/* We count the total bytes sent, and the send rate for 32-byte blocks.
|
||||||
|
* The reason for the latter is that freq_ctr are limited to 4GB and
|
||||||
|
* that it's not enough per second.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (splice)
|
||||||
|
_HA_ATOMIC_ADD(&th_ctx->spliced_out_bytes, bytes);
|
||||||
|
_HA_ATOMIC_ADD(&th_ctx->out_bytes, bytes);
|
||||||
|
update_freq_ctr(&th_ctx->out_32bps, (bytes + 16) / 32);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _HAPROXY_PROXY_H */
|
#endif /* _HAPROXY_PROXY_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <haproxy/api.h>
|
#include <haproxy/api.h>
|
||||||
#include <haproxy/connection.h>
|
#include <haproxy/connection.h>
|
||||||
#include <haproxy/dynbuf.h>
|
#include <haproxy/dynbuf.h>
|
||||||
#include <haproxy/freq_ctr.h>
|
|
||||||
#include <haproxy/h3.h>
|
#include <haproxy/h3.h>
|
||||||
#include <haproxy/list.h>
|
#include <haproxy/list.h>
|
||||||
#include <haproxy/ncbuf.h>
|
#include <haproxy/ncbuf.h>
|
||||||
@ -20,7 +19,6 @@
|
|||||||
#include <haproxy/quic_tp-t.h>
|
#include <haproxy/quic_tp-t.h>
|
||||||
#include <haproxy/ssl_sock-t.h>
|
#include <haproxy/ssl_sock-t.h>
|
||||||
#include <haproxy/stconn.h>
|
#include <haproxy/stconn.h>
|
||||||
#include <haproxy/thread.h>
|
|
||||||
#include <haproxy/trace.h>
|
#include <haproxy/trace.h>
|
||||||
|
|
||||||
DECLARE_POOL(pool_head_qcc, "qcc", sizeof(struct qcc));
|
DECLARE_POOL(pool_head_qcc, "qcc", sizeof(struct qcc));
|
||||||
@ -1648,13 +1646,8 @@ void qcc_streams_sent_done(struct qcs *qcs, uint64_t data, uint64_t offset)
|
|||||||
|
|
||||||
/* Add measurement for send rate. This is done at the MUX layer
|
/* Add measurement for send rate. This is done at the MUX layer
|
||||||
* to account only for STREAM frames without retransmission.
|
* to account only for STREAM frames without retransmission.
|
||||||
*
|
|
||||||
* we count the total bytes sent, and the send rate for 32-byte blocks.
|
|
||||||
* The reason for the latter is that freq_ctr are limited to 4GB and
|
|
||||||
* that it's not enough per second.
|
|
||||||
*/
|
*/
|
||||||
_HA_ATOMIC_ADD(&th_ctx->out_bytes, ret);
|
increment_send_rate(diff, 0);
|
||||||
update_freq_ctr(&th_ctx->out_32bps, (ret + 16) / 32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qcs->tx.offset == qcs->tx.sent_offset && !b_data(&qcs->tx.buf)) {
|
if (qcs->tx.offset == qcs->tx.sent_offset && !b_data(&qcs->tx.buf)) {
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
#include <haproxy/connection.h>
|
#include <haproxy/connection.h>
|
||||||
#include <haproxy/errors.h>
|
#include <haproxy/errors.h>
|
||||||
#include <haproxy/fd.h>
|
#include <haproxy/fd.h>
|
||||||
#include <haproxy/freq_ctr.h>
|
|
||||||
#include <haproxy/global.h>
|
#include <haproxy/global.h>
|
||||||
#include <haproxy/pipe.h>
|
#include <haproxy/pipe.h>
|
||||||
|
#include <haproxy/proxy.h>
|
||||||
#include <haproxy/tools.h>
|
#include <haproxy/tools.h>
|
||||||
|
|
||||||
|
|
||||||
@ -147,15 +147,9 @@ int raw_sock_to_pipe(struct connection *conn, void *xprt_ctx, struct pipe *pipe,
|
|||||||
conn->flags &= ~CO_FL_WAIT_L4_CONN;
|
conn->flags &= ~CO_FL_WAIT_L4_CONN;
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
if (retval > 0) {
|
if (retval > 0)
|
||||||
/* we count the total bytes sent, and the send rate for 32-byte
|
increment_send_rate(retval, 1);
|
||||||
* blocks. The reason for the latter is that freq_ctr are
|
|
||||||
* limited to 4GB and that it's not enough per second.
|
|
||||||
*/
|
|
||||||
_HA_ATOMIC_ADD(&th_ctx->out_bytes, retval);
|
|
||||||
_HA_ATOMIC_ADD(&th_ctx->spliced_out_bytes, retval);
|
|
||||||
update_freq_ctr(&th_ctx->out_32bps, (retval + 16) / 32);
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
out_read0:
|
out_read0:
|
||||||
@ -416,14 +410,9 @@ static size_t raw_sock_from_buf(struct connection *conn, void *xprt_ctx, const s
|
|||||||
conn->flags &= ~CO_FL_WAIT_L4_CONN;
|
conn->flags &= ~CO_FL_WAIT_L4_CONN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done > 0) {
|
if (done > 0)
|
||||||
/* we count the total bytes sent, and the send rate for 32-byte
|
increment_send_rate(done, 0);
|
||||||
* blocks. The reason for the latter is that freq_ctr are
|
|
||||||
* limited to 4GB and that it's not enough per second.
|
|
||||||
*/
|
|
||||||
_HA_ATOMIC_ADD(&th_ctx->out_bytes, done);
|
|
||||||
update_freq_ctr(&th_ctx->out_32bps, (done + 16) / 32);
|
|
||||||
}
|
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user