Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small optimizations for XQUIC #410

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/transport/scheduler/xqc_scheduler_backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ xqc_backup_scheduler_get_path(void *scheduler, xqc_connection_t *conn,
xqc_packet_out_t *packet_out, int check_cwnd, int reinject,
xqc_bool_t *cc_blocked)
{
xqc_path_ctx_t *best_path[XQC_PATH_CLASS_PERF_CLASS_SIZE];
xqc_bool_t has_path[XQC_PATH_CLASS_PERF_CLASS_SIZE];
xqc_path_ctx_t *best_path[XQC_PATH_CLASS_PERF_CLASS_SIZE] = { NULL };
xqc_bool_t has_path[XQC_PATH_CLASS_PERF_CLASS_SIZE] = { XQC_FALSE };
xqc_path_perf_class_t path_class;
xqc_bool_t available_path_exists;

Expand All @@ -44,14 +44,6 @@ xqc_backup_scheduler_get_path(void *scheduler, xqc_connection_t *conn,
*cc_blocked = XQC_FALSE;
}

for (path_class = XQC_PATH_CLASS_AVAILABLE_HIGH;
path_class < XQC_PATH_CLASS_PERF_CLASS_SIZE;
path_class++)
{
best_path[path_class] = NULL;
has_path[path_class] = XQC_FALSE;
}

xqc_list_for_each_safe(pos, next, &conn->conn_paths_list) {
path = xqc_list_entry(pos, xqc_path_ctx_t, path_list);

Expand Down Expand Up @@ -87,7 +79,7 @@ xqc_backup_scheduler_get_path(void *scheduler, xqc_connection_t *conn,
path_srtt = xqc_send_ctl_get_srtt(path->path_send_ctl);

if (best_path[path_class] == NULL
|| path_srtt < best_path[path_class]->path_send_ctl->ctl_srtt)
|| path_srtt < xqc_send_ctl_get_srtt(best_path[path_class]->path_send_ctl))
{
best_path[path_class] = path;
}
Expand Down
2 changes: 1 addition & 1 deletion src/transport/scheduler/xqc_scheduler_backup.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

extern const xqc_scheduler_callback_t xqc_backup_scheduler_cb;

#endif /* _XQC_SCHEDULER_BACKUP_H_INCLUDED_ */
#endif /* _XQC_SCHEDULER_BACKUP_H_INCLUDED_ */
2 changes: 1 addition & 1 deletion src/transport/scheduler/xqc_scheduler_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

xqc_bool_t xqc_scheduler_check_path_can_send(xqc_path_ctx_t *path, xqc_packet_out_t *packet_out, int check_cwnd);

#endif
#endif /* _XQC_SCHEDULER_COMMON_H_INCLUDED_ */
3 changes: 1 addition & 2 deletions src/transport/scheduler/xqc_scheduler_interop.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ xqc_interop_scheduler_get_path(void *scheduler,
if (path->app_path_status == XQC_APP_PATH_STATUS_AVAILABLE) {
best_path = path;
min_rtt = path_srtt;

} else {
best_standby_path = path;
min_rtt_standby = path_srtt;
Expand Down Expand Up @@ -112,4 +111,4 @@ const xqc_scheduler_callback_t xqc_interop_scheduler_cb = {
.xqc_scheduler_size = xqc_interop_scheduler_size,
.xqc_scheduler_init = xqc_interop_scheduler_init,
.xqc_scheduler_get_path = xqc_interop_scheduler_get_path,
};
};
2 changes: 1 addition & 1 deletion src/transport/scheduler/xqc_scheduler_interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

extern const xqc_scheduler_callback_t xqc_interop_scheduler_cb;

#endif
#endif /* _XQC_SCHEDULER_INTEROP_H_INCLUDED_ */
11 changes: 1 addition & 10 deletions src/transport/scheduler/xqc_scheduler_minrtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "src/transport/scheduler/xqc_scheduler_common.h"
#include "src/transport/xqc_send_ctl.h"


static size_t
xqc_minrtt_scheduler_size()
{
Expand All @@ -25,8 +24,8 @@ xqc_minrtt_scheduler_get_path(void *scheduler,
xqc_connection_t *conn, xqc_packet_out_t *packet_out, int check_cwnd, int reinject,
xqc_bool_t *cc_blocked)
{
xqc_path_ctx_t *best_path[XQC_PATH_CLASS_PERF_CLASS_SIZE];
xqc_path_perf_class_t path_class;
xqc_path_ctx_t *best_path[XQC_PATH_CLASS_PERF_CLASS_SIZE] = { NULL };

xqc_list_head_t *pos, *next;
xqc_path_ctx_t *path;
Expand All @@ -37,13 +36,6 @@ xqc_minrtt_scheduler_get_path(void *scheduler,
xqc_bool_t reached_cwnd_check = XQC_FALSE;
xqc_bool_t path_can_send;

for (path_class = XQC_PATH_CLASS_AVAILABLE_HIGH;
path_class < XQC_PATH_CLASS_PERF_CLASS_SIZE;
path_class++)
{
best_path[path_class] = NULL;
}

if (cc_blocked) {
*cc_blocked = XQC_FALSE;
}
Expand Down Expand Up @@ -103,7 +95,6 @@ xqc_minrtt_scheduler_get_path(void *scheduler,
best_path[path_class] ? best_path[path_class]->path_id : -1);
}


for (path_class = XQC_PATH_CLASS_AVAILABLE_HIGH;
path_class < XQC_PATH_CLASS_PERF_CLASS_SIZE;
path_class++)
Expand Down
2 changes: 1 addition & 1 deletion src/transport/scheduler/xqc_scheduler_minrtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

extern const xqc_scheduler_callback_t xqc_minrtt_scheduler_cb;

#endif /* _XQC_SCHEDULER_MINRTT_H_INCLUDED_ */
#endif /* _XQC_SCHEDULER_MINRTT_H_INCLUDED_ */
2 changes: 1 addition & 1 deletion src/transport/scheduler/xqc_scheduler_rap.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

extern const xqc_scheduler_callback_t xqc_rap_scheduler_cb;

#endif
#endif /* _XQC_SCHEDULER_MINRTT_H_INCLUDED_ */
25 changes: 17 additions & 8 deletions src/transport/xqc_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,38 +437,52 @@ xqc_engine_create(xqc_engine_type_t engine_type,
engine->config->cfg_log_event,
engine->config->cfg_log_timestamp,
engine->config->cfg_log_level_name,
&engine->eng_callback.log_callbacks, engine->user_data);
&engine->eng_callback.log_callbacks,
engine->user_data);

if (engine->log == NULL) {
goto fail;
}

engine->rand_generator = xqc_random_generator_create(engine->log);
if (engine->rand_generator == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to initialize random generator in engine|");
goto fail;
}

engine->conns_hash = xqc_engine_conns_hash_create(engine->config);
if (engine->conns_hash == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create connections hash|");
goto fail;
}

engine->conns_hash_dcid = xqc_engine_conns_hash_create(engine->config);
if (engine->conns_hash_dcid == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create connections hash for reset packets|");
goto fail;
}

engine->conns_hash_sr_token = xqc_engine_conns_hash_create(engine->config);
if (engine->conns_hash_sr_token == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create connections hash for stateless reset|");
goto fail;
}

engine->conns_active_pq = xqc_engine_conns_pq_create(engine->config);
if (engine->conns_active_pq == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create priority queue|");
goto fail;
}

engine->conns_wait_wakeup_pq = xqc_engine_wakeup_pq_create(engine->config);
if (engine->conns_wait_wakeup_pq == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create wakeup priority queue|");
goto fail;
}

Expand All @@ -477,11 +491,12 @@ xqc_engine_create(xqc_engine_type_t engine_type,
engine->tls_ctx = xqc_tls_ctx_create((xqc_tls_type_t)engine->eng_type, ssl_config,
&xqc_conn_tls_cbs, engine->log);
if (NULL == engine->tls_ctx) {
xqc_log(engine->log, XQC_LOG_ERROR, "|create tls context error");
xqc_log(engine->log, XQC_LOG_ERROR, "|create tls context error|");
goto fail;
}

} else {
xqc_log(engine->log, XQC_LOG_ERROR, "|invalid SSL configuration|");
goto fail;
}

Expand Down Expand Up @@ -1321,12 +1336,6 @@ xqc_engine_packet_process(xqc_engine_t *engine,
}








uint8_t
xqc_engine_config_get_cid_len(xqc_engine_t *engine)
{
Expand Down
3 changes: 1 addition & 2 deletions src/transport/xqc_multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ xqc_path_create(xqc_connection_t *conn, xqc_cid_t *scid, xqc_cid_t *dcid)
if (path == NULL) {
return NULL;
}
xqc_memzero(path, sizeof(xqc_path_ctx_t));

path->path_state = XQC_PATH_STATE_INIT;
path->parent_conn = conn;
Expand Down Expand Up @@ -466,7 +465,7 @@ xqc_conn_create_path(xqc_engine_t *engine, const xqc_cid_t *scid, uint64_t *new_

path = xqc_conn_create_path_inner(conn, NULL, NULL, ps_inner);
if (path == NULL) {
xqc_log(conn->log, XQC_LOG_ERROR, "|xqc_path_create error|");
xqc_log(conn->log, XQC_LOG_ERROR, "|xqc_conn_create_path_inner error|");
return -XQC_EMP_CREATE_PATH;
}

Expand Down
7 changes: 0 additions & 7 deletions src/transport/xqc_send_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1699,13 +1699,6 @@ xqc_send_ctl_get_earliest_loss_time(xqc_send_ctl_t *send_ctl, xqc_pkt_num_space_
return time;
}


xqc_usec_t
xqc_send_ctl_get_srtt(xqc_send_ctl_t *send_ctl)
{
return send_ctl->ctl_srtt;
}

float
xqc_send_ctl_get_retrans_rate(xqc_send_ctl_t *send_ctl)
{
Expand Down
4 changes: 3 additions & 1 deletion src/transport/xqc_send_ctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ void xqc_send_ctl_set_loss_detection_timer(xqc_send_ctl_t *send_ctl);

xqc_usec_t xqc_send_ctl_get_earliest_loss_time(xqc_send_ctl_t *send_ctl, xqc_pkt_num_space_t *pns_ret);

xqc_usec_t xqc_send_ctl_get_srtt(xqc_send_ctl_t *send_ctl);
static inline xqc_usec_t xqc_send_ctl_get_srtt(xqc_send_ctl_t *send_ctl) {
return send_ctl->ctl_srtt;
}

float xqc_send_ctl_get_retrans_rate(xqc_send_ctl_t *send_ctl);

Expand Down
12 changes: 0 additions & 12 deletions tests/test_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,6 @@ xqc_convert_addr_text_to_sockaddr(int type,
{
if (type == AF_INET6) {
*saddr = calloc(1, sizeof(struct sockaddr_in6));
memset(*saddr, 0, sizeof(struct sockaddr_in6));
struct sockaddr_in6 *addr_v6 = (struct sockaddr_in6 *)(*saddr);
inet_pton(type, addr_text, &(addr_v6->sin6_addr.s6_addr));
addr_v6->sin6_family = type;
Expand All @@ -1470,7 +1469,6 @@ xqc_convert_addr_text_to_sockaddr(int type,

} else {
*saddr = calloc(1, sizeof(struct sockaddr_in));
memset(*saddr, 0, sizeof(struct sockaddr_in));
struct sockaddr_in *addr_v4 = (struct sockaddr_in *)(*saddr);
inet_pton(type, addr_text, &(addr_v4->sin_addr.s_addr));
addr_v4->sin_family = type;
Expand All @@ -1491,12 +1489,10 @@ xqc_client_init_addr(user_conn_t *user_conn,

if (ip_type == AF_INET6) {
user_conn->local_addr = (struct sockaddr *)calloc(1, sizeof(struct sockaddr_in6));
memset(user_conn->local_addr, 0, sizeof(struct sockaddr_in6));
user_conn->local_addrlen = sizeof(struct sockaddr_in6);

} else {
user_conn->local_addr = (struct sockaddr *)calloc(1, sizeof(struct sockaddr_in));
memset(user_conn->local_addr, 0, sizeof(struct sockaddr_in));
user_conn->local_addrlen = sizeof(struct sockaddr_in);
}
}
Expand All @@ -1512,13 +1508,6 @@ xqc_client_create_path_socket(xqc_user_path_t *path,
return XQC_ERROR;
}
#ifndef XQC_SYS_WINDOWS
if (path_interface != NULL
&& xqc_client_bind_to_interface(path->path_fd, path_interface) < 0)
Ya-Pasha-364shy marked this conversation as resolved.
Show resolved Hide resolved
{
printf("|xqc_client_bind_to_interface error|");
return XQC_ERROR;
}

if (g_test_case == 103 || g_test_case == 104) {
path->rebinding_path_fd = xqc_client_create_socket((g_ipv6 ? AF_INET6 : AF_INET),
path->peer_addr, path->peer_addrlen, path_interface);
Expand Down Expand Up @@ -3418,7 +3407,6 @@ xqc_client_timeout_callback(int fd, short what, void *arg)
restart_after_a_while--;
//we don't care the memory leak caused by user_stream. It's just for one-shot testing. :D
user_stream_t *user_stream = calloc(1, sizeof(user_stream_t));
memset(user_stream, 0, sizeof(user_stream_t));
user_stream->user_conn = user_conn;
printf("gtest 15: restart from idle!\n");
user_stream->stream = xqc_stream_create(ctx.engine, &(user_conn->cid), NULL, user_stream);
Expand Down