[Pkg-voip-commits] [janus] 178/282: Experiments to improve performance of the ICE send thread
Jonas Smedegaard
dr at jones.dk
Wed Dec 20 21:53:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/0.2.6-1
in repository janus.
commit 634007f186d2491c7eb2dba234e5c1a2edc7bb47
Author: Lorenzo Miniero <lminiero at gmail.com>
Date: Sat Nov 11 05:03:29 2017 +0100
Experiments to improve performance of the ICE send thread
---
ice.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
ice.h | 6 +++---
2 files changed, 59 insertions(+), 11 deletions(-)
diff --git a/ice.c b/ice.c
index 0e6ef49..443ee11 100644
--- a/ice.c
+++ b/ice.c
@@ -958,6 +958,7 @@ void janus_ice_stats_reset(janus_ice_stats *stats) {
if(stats->audio_bytes_lastsec)
g_list_free_full(stats->audio_bytes_lastsec, &janus_ice_stats_queue_free);
stats->audio_bytes_lastsec = NULL;
+ stats->audio_bytes_lastsec_last = NULL;
stats->audio_notified_lastsec = FALSE;
stats->audio_nacks = 0;
stats->video_packets = 0;
@@ -965,6 +966,7 @@ void janus_ice_stats_reset(janus_ice_stats *stats) {
if(stats->video_bytes_lastsec)
g_list_free_full(stats->video_bytes_lastsec, &janus_ice_stats_queue_free);
stats->video_bytes_lastsec = NULL;
+ stats->video_bytes_lastsec_last = NULL;
stats->video_notified_lastsec = FALSE;
stats->video_nacks = 0;
stats->data_packets = 0;
@@ -1392,6 +1394,8 @@ void janus_ice_component_free(GHashTable *components, janus_ice_component *compo
g_free(p);
first = g_list_first(component->retransmit_buffer);
}
+ component->retransmit_buffer = NULL;
+ component->retransmit_buffer_last = NULL;
}
if(component->candidates != NULL) {
GSList *i = NULL, *candidates = component->candidates;
@@ -2088,13 +2092,26 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
}
component->in_stats.audio_packets++;
component->in_stats.audio_bytes += buflen;
- component->in_stats.audio_bytes_lastsec = g_list_append(component->in_stats.audio_bytes_lastsec, s);
+ GList *last = g_list_alloc();
+ last->data = s;
+ last->next = NULL;
+ last->prev = NULL;
+ if(component->in_stats.audio_bytes_lastsec_last == NULL) {
+ /* First stat in queue */
+ component->in_stats.audio_bytes_lastsec = last;
+ component->in_stats.audio_bytes_lastsec_last = last;
+ } else {
+ /* Append after last stat in queue */
+ component->in_stats.audio_bytes_lastsec_last->next = last;
+ last->prev = component->in_stats.audio_bytes_lastsec_last;
+ component->in_stats.audio_bytes_lastsec_last = last;
+ }
if(g_list_length(component->in_stats.audio_bytes_lastsec) > 100) {
GList *first = g_list_first(component->in_stats.audio_bytes_lastsec);
s = (janus_ice_stats_item *)first->data;
+ g_free(s);
first->data = NULL;
component->in_stats.audio_bytes_lastsec = g_list_delete_link(component->in_stats.audio_bytes_lastsec, first);
- g_free(s);
}
} else {
if(component->in_stats.video_bytes == 0 || component->in_stats.video_notified_lastsec) {
@@ -2104,13 +2121,26 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
}
component->in_stats.video_packets++;
component->in_stats.video_bytes += buflen;
- component->in_stats.video_bytes_lastsec = g_list_append(component->in_stats.video_bytes_lastsec, s);
+ GList *last = g_list_alloc();
+ last->data = s;
+ last->next = NULL;
+ last->prev = NULL;
+ if(component->in_stats.video_bytes_lastsec_last == NULL) {
+ /* First stat in queue */
+ component->in_stats.video_bytes_lastsec = last;
+ component->in_stats.video_bytes_lastsec_last = last;
+ } else {
+ /* Append after last stat in queue */
+ component->in_stats.video_bytes_lastsec_last->next = last;
+ last->prev = component->in_stats.video_bytes_lastsec_last;
+ component->in_stats.video_bytes_lastsec_last = last;
+ }
if(g_list_length(component->in_stats.video_bytes_lastsec) > 100) {
GList *first = g_list_first(component->in_stats.video_bytes_lastsec);
s = (janus_ice_stats_item *)first->data;
+ g_free(s);
first->data = NULL;
component->in_stats.video_bytes_lastsec = g_list_delete_link(component->in_stats.video_bytes_lastsec, first);
- g_free(s);
}
}
janus_mutex_unlock(&component->mutex);
@@ -3033,6 +3063,7 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
audio_rtp->do_audio_nacks = FALSE;
audio_rtp->do_video_nacks = FALSE;
audio_rtp->retransmit_buffer = NULL;
+ audio_rtp->retransmit_buffer_last = NULL;
audio_rtp->retransmit_log_ts = 0;
audio_rtp->retransmit_recent_cnt = 0;
audio_rtp->nack_sent_log_ts = 0;
@@ -3099,6 +3130,7 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
audio_rtcp->do_audio_nacks = FALSE;
audio_rtcp->do_video_nacks = FALSE;
audio_rtcp->retransmit_buffer = NULL;
+ audio_rtcp->retransmit_buffer_last = NULL;
audio_rtcp->retransmit_log_ts = 0;
audio_rtcp->retransmit_recent_cnt = 0;
janus_ice_stats_reset(&audio_rtcp->in_stats);
@@ -3196,6 +3228,7 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
video_rtp->do_audio_nacks = FALSE;
video_rtp->do_video_nacks = FALSE;
video_rtp->retransmit_buffer = NULL;
+ video_rtp->retransmit_buffer_last = NULL;
video_rtp->retransmit_log_ts = 0;
video_rtp->retransmit_recent_cnt = 0;
video_rtp->nack_sent_log_ts = 0;
@@ -3262,6 +3295,7 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
video_rtcp->do_audio_nacks = FALSE;
video_rtcp->do_video_nacks = FALSE;
video_rtcp->retransmit_buffer = NULL;
+ video_rtcp->retransmit_buffer_last = NULL;
video_rtcp->retransmit_log_ts = 0;
video_rtcp->retransmit_recent_cnt = 0;
janus_ice_stats_reset(&video_rtcp->in_stats);
@@ -3354,6 +3388,7 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
data_component->do_audio_nacks = FALSE;
data_component->do_video_nacks = FALSE;
data_component->retransmit_buffer = NULL;
+ data_component->retransmit_buffer_last = NULL;
data_component->retransmit_log_ts = 0;
data_component->retransmit_recent_cnt = 0;
janus_ice_stats_reset(&data_component->in_stats);
@@ -3447,7 +3482,7 @@ void *janus_ice_send_thread(void *data) {
if(no_media_timer > 0 && now-before >= G_USEC_PER_SEC) {
if(handle->audio_stream && handle->audio_stream->rtp_component) {
janus_ice_component *component = handle->audio_stream->rtp_component;
- GList *lastitem = g_list_last(component->in_stats.audio_bytes_lastsec);
+ GList *lastitem = component->in_stats.audio_bytes_lastsec_last;
janus_ice_stats_item *last = lastitem ? ((janus_ice_stats_item *)lastitem->data) : NULL;
if(!component->in_stats.audio_notified_lastsec && last && now-last->when >= (gint64)no_media_timer*G_USEC_PER_SEC) {
/* We missed more than no_second_timer seconds of audio! */
@@ -3456,7 +3491,7 @@ void *janus_ice_send_thread(void *data) {
janus_ice_notify_media(handle, FALSE, FALSE);
}
if(!component->in_stats.video_notified_lastsec && janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_BUNDLE)) {
- lastitem = g_list_last(component->in_stats.video_bytes_lastsec);
+ lastitem = component->in_stats.video_bytes_lastsec_last;
last = lastitem ? ((janus_ice_stats_item *)lastitem->data) : NULL;
if(last && now-last->when >= (gint64)no_media_timer*G_USEC_PER_SEC) {
/* We missed more than no_second_timer seconds of video! */
@@ -3468,7 +3503,7 @@ void *janus_ice_send_thread(void *data) {
}
if(handle->video_stream && handle->video_stream->rtp_component) {
janus_ice_component *component = handle->video_stream->rtp_component;
- GList *lastitem = g_list_last(component->in_stats.video_bytes_lastsec);
+ GList *lastitem = component->in_stats.video_bytes_lastsec_last;
janus_ice_stats_item *last = lastitem ? ((janus_ice_stats_item *)lastitem->data) : NULL;
if(!component->in_stats.video_notified_lastsec && last && now-last->when >= (gint64)no_media_timer*G_USEC_PER_SEC) {
/* We missed more than no_second_timer seconds of video! */
@@ -3942,7 +3977,20 @@ void *janus_ice_send_thread(void *data) {
p->created = janus_get_monotonic_time();
p->last_retransmit = 0;
janus_mutex_lock(&component->mutex);
- component->retransmit_buffer = g_list_append(component->retransmit_buffer, p);
+ GList *last = g_list_alloc();
+ last->data = p;
+ last->next = NULL;
+ last->prev = NULL;
+ if(component->retransmit_buffer_last == NULL) {
+ /* First packet in queue */
+ component->retransmit_buffer = last;
+ component->retransmit_buffer_last = last;
+ } else {
+ /* Append after last packet in queue */
+ component->retransmit_buffer_last->next = last;
+ last->prev = component->retransmit_buffer_last;
+ component->retransmit_buffer_last = last;
+ }
janus_mutex_unlock(&component->mutex);
}
}
diff --git a/ice.h b/ice.h
index 0a0f7ec..2a5121d 100644
--- a/ice.h
+++ b/ice.h
@@ -194,7 +194,7 @@ typedef struct janus_ice_stats {
/*! \brief Audio bytes sent or received */
guint64 audio_bytes;
/*! \brief Audio bytes sent or received in the last second */
- GList *audio_bytes_lastsec;
+ GList *audio_bytes_lastsec, *audio_bytes_lastsec_last;
/*! \brief Whether or not we notified about audio lastsec issues already */
gboolean audio_notified_lastsec;
/*! \brief Number of audio NACKs sent or received */
@@ -204,7 +204,7 @@ typedef struct janus_ice_stats {
/*! \brief Video bytes sent or received */
guint64 video_bytes;
/*! \brief Video bytes sent or received in the last second */
- GList *video_bytes_lastsec;
+ GList *video_bytes_lastsec, *video_bytes_lastsec_last;
/*! \brief Whether or not we notified about video lastsec issues already */
gboolean video_notified_lastsec;
/*! \brief Number of video NACKs sent or received */
@@ -450,7 +450,7 @@ struct janus_ice_component {
/*! \brief Whether we should do NACKs (in or out) for video */
gboolean do_video_nacks;
/*! \brief List of previously sent janus_rtp_packet RTP packets, in case we receive NACKs */
- GList *retransmit_buffer;
+ GList *retransmit_buffer, *retransmit_buffer_last;
/*! \brief Last time a log message about sending retransmits was printed */
gint64 retransmit_log_ts;
/*! \brief Number of retransmitted packets since last log message */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git
More information about the Pkg-voip-commits
mailing list