Skip to content

Commit 5cca527

Browse files
committed
MINOR: mux-quic: use sched call time for pacing
QUIC pacing was recently implemented to limit burst and improve overall bandwidth. This is used only for MUX STREAM emission. Pacing requires nanosecond resolution. As such, it used now_cpu_time() which relies on clock_gettime() syscall. The usage of clock_gettime() as several drawbacks : * it is a syscall and requires a context-switch * it is not be available on all systems * value is changing accross a single task execution which may tamper pacing calculation Improve this by using task_mono_time() instead. This requires the flag TASK_F_WANTS_TIME on QUIC MUX tasklet to require the scheduler to update sched call time with now_mono_time(). This solves any limitations listed above : * syscall invokation is only performed once before tasklet execution, thus reducing context-switch impact * on non compatible system, a millisecond timer is used as a fallback which should ensure that pacing works decently for them * timer value is now guaranteed to be fixed duing task execution
1 parent 614adda commit 5cca527

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

include/haproxy/mux_quic-t.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <haproxy/quic_pacing-t.h>
1919
#include <haproxy/quic_stream-t.h>
2020
#include <haproxy/stconn-t.h>
21+
#include <haproxy/task-t.h>
2122
#include <haproxy/time-t.h>
2223

2324
/* Stream types */

src/mux_quic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,7 @@ static int qmux_init(struct connection *conn, struct proxy *prx,
29962996

29972997
qcc->wait_event.tasklet->process = qcc_io_cb;
29982998
qcc->wait_event.tasklet->context = qcc;
2999+
qcc->wait_event.tasklet->state |= TASK_F_WANTS_TIME;
29993000
qcc->wait_event.events = 0;
30003001

30013002
qcc->proxy = prx;

src/quic_pacing.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#include <haproxy/quic_pacing.h>
22

33
#include <haproxy/quic_tx.h>
4+
#include <haproxy/task.h>
45

56
/* Returns true if <pacer> timer is expired and emission can be retried. */
67
int quic_pacing_expired(const struct quic_pacer *pacer)
78
{
8-
return !pacer->next || pacer->next <= now_mono_time();
9+
return !pacer->next || pacer->next <= task_mono_time();
910
}
1011

1112
/* Notify <pacer> about an emission of <sent> count of datagrams. */
1213
void quic_pacing_sent_done(struct quic_pacer *pacer, int sent)
1314
{
14-
pacer->next = now_mono_time() + pacer->cc->algo->pacing_rate(pacer->cc) * sent;
15+
pacer->next = task_mono_time() + pacer->cc->algo->pacing_rate(pacer->cc) * sent;
1516
pacer->last_sent = sent;
1617
}

0 commit comments

Comments
 (0)