Skip to content

Commit

Permalink
MINOR: mux-quic: use sched call time for pacing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
a-denoyelle committed Nov 22, 2024
1 parent 602dbe5 commit ebd1c3f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/haproxy/mux_quic-t.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <haproxy/quic_pacing-t.h>
#include <haproxy/quic_stream-t.h>
#include <haproxy/stconn-t.h>
#include <haproxy/task-t.h>
#include <haproxy/time-t.h>

/* Stream types */
Expand Down
1 change: 1 addition & 0 deletions src/mux_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2996,6 +2996,7 @@ static int qmux_init(struct connection *conn, struct proxy *prx,

qcc->wait_event.tasklet->process = qcc_io_cb;
qcc->wait_event.tasklet->context = qcc;
qcc->wait_event.tasklet->state |= TASK_F_WANTS_TIME;
qcc->wait_event.events = 0;

qcc->proxy = prx;
Expand Down
5 changes: 3 additions & 2 deletions src/quic_pacing.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#include <haproxy/quic_pacing.h>

#include <haproxy/quic_tx.h>
#include <haproxy/task.h>

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

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

0 comments on commit ebd1c3f

Please sign in to comment.