--
You received this message because you are subscribed to a topic in the Google Groups "meetecho-janus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meetecho-janus/8_XGmAnOv-4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meetecho-janus+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Then I tried something else. I tried to get rid completely of this "per handle data packet queue" in Janus. So basically I modified janus_ice_relay_rtp to send packets directly instead of pushing them up into the queue. And no more NACKS in this case...I was quite confident it would fix my problem, but it didn't!My first intuition was that my problem was due to this libnice issue I had heard about. So I asked the question on this forum and I added a function to libnice called "nice_agent_send_data_nolock" for the sending of data packets only, and which basically calls nice_socket_send_messages without holding any lock, so a very simple function. I replaced all the calls to nice_agent_send in janus_ice_send_thread with calls to my new function.My testbed is quite simple, I have 1 input stream at a quite heavy bitrate (around 6/7Mbps), and 1 output stream. Janus in this case receives lot of NACKS from the receiver of the output stream while I don't have any packet losses on the receive side (verified also with a wireshark capture). I would have to do more testing but it seems I start receiving these NACKS with bitrates higher than 4Mbps.I've then tested harder this afternoon trying to narrow down what exactly my problem is.Hi Lorenzo,Thanks for your detailed answer! It's cool to have a complete status regarding this.So probably a lock contention issue related to async_queue_push/pop functions, or may it be something else?I don't have time to do more investigations right now, and will not be able to work back on this till thursday next week, but I wanted to share this with you anyway, even if I don't have a clear conclusion yet!
Thanks for digging more on this. I only see a couple of those instances: we use g_list_last to calculate how many bytes we sent in the last second (or whatever no_media_timer is set to), and g_list_append only to update the list of packets to retransmit. I guess the former could be redone without a list at all, not sure about the latter. Anyway, it's a GList, which means it's a double linked list: I'd expect a g_list_last or append to go ->prev from the head, instead of crawling the whole list the other way around.
g_list_prepend() and reverse
the list with g_list_reverse() when all elements have been added."Nothing we can do about the MTU, instead: it's up to the source to send smaller packets. Being so close to the MTU, SRTP overhead or not, is still dangerous, as it's not that unusual to encounter netork paths with MTUs smaller than average.
2017-11-10 3:30 GMT+01:00 Lorenzo Miniero <lmin...@gmail.com>:Thanks for digging more on this. I only see a couple of those instances: we use g_list_last to calculate how many bytes we sent in the last second (or whatever no_media_timer is set to), and g_list_append only to update the list of packets to retransmit. I guess the former could be redone without a list at all, not sure about the latter. Anyway, it's a GList, which means it's a double linked list: I'd expect a g_list_last or append to go ->prev from the head, instead of crawling the whole list the other way around.Hi Lorenzo,It's true it's a double linked list but unfortunately, as mentioned in glib documentation g_list_append/g_list_last don't work as we would expect:"g_list_append() has to traverse the entire list to find the end, which is inefficient when adding multiple elements. A common idiom to avoid the inefficiency is to useg_list_prepend()and reverse the list withg_list_reverse()when all elements have been added."
Il giorno venerdì 10 novembre 2017 10:07:18 UTC+1, Emmanuel Riou ha scritto:2017-11-10 3:30 GMT+01:00 Lorenzo Miniero <lmin...@gmail.com>:Thanks for digging more on this. I only see a couple of those instances: we use g_list_last to calculate how many bytes we sent in the last second (or whatever no_media_timer is set to), and g_list_append only to update the list of packets to retransmit. I guess the former could be redone without a list at all, not sure about the latter. Anyway, it's a GList, which means it's a double linked list: I'd expect a g_list_last or append to go ->prev from the head, instead of crawling the whole list the other way around.Hi Lorenzo,It's true it's a double linked list but unfortunately, as mentioned in glib documentation g_list_append/g_list_last don't work as we would expect:"g_list_append() has to traverse the entire list to find the end, which is inefficient when adding multiple elements. A common idiom to avoid the inefficiency is to useg_list_prepend()and reverse the list withg_list_reverse()when all elements have been added."Not sure how more efficient that would be: wouldn't g_list_reverse() have to traverse the whole list too, to invert all the ->next and ->prev pointers? It sounds easier and quicker to do g_list_prepend() and not reverse at all, but only make sure the head of the list is still the same it was before.
Anyway, as a quick test you can try preventing the code to store the retransmitted packet at all, and see how much it improves for you: if it's considerable, we can think of better ways to do the same thing, e.g., using the method described above.
2017-11-10 10:19 GMT+01:00 Lorenzo Miniero <lmin...@gmail.com>:Il giorno venerdì 10 novembre 2017 10:07:18 UTC+1, Emmanuel Riou ha scritto:2017-11-10 3:30 GMT+01:00 Lorenzo Miniero <lmin...@gmail.com>:Thanks for digging more on this. I only see a couple of those instances: we use g_list_last to calculate how many bytes we sent in the last second (or whatever no_media_timer is set to), and g_list_append only to update the list of packets to retransmit. I guess the former could be redone without a list at all, not sure about the latter. Anyway, it's a GList, which means it's a double linked list: I'd expect a g_list_last or append to go ->prev from the head, instead of crawling the whole list the other way around.Hi Lorenzo,It's true it's a double linked list but unfortunately, as mentioned in glib documentation g_list_append/g_list_last don't work as we would expect:"g_list_append() has to traverse the entire list to find the end, which is inefficient when adding multiple elements. A common idiom to avoid the inefficiency is to useg_list_prepend()and reverse the list withg_list_reverse()when all elements have been added."Not sure how more efficient that would be: wouldn't g_list_reverse() have to traverse the whole list too, to invert all the ->next and ->prev pointers? It sounds easier and quicker to do g_list_prepend() and not reverse at all, but only make sure the head of the list is still the same it was before.g_list_reverse is not efficient either, but as mentioned in the documentation you do it only once, once the list is complete, which is not relevant for us. So yes g_list_prepend instead of g_list_append would be the solution.
Anyway, as a quick test you can try preventing the code to store the retransmitted packet at all, and see how much it improves for you: if it's considerable, we can think of better ways to do the same thing, e.g., using the method described above.I've done this test already, it is clearly really better without the retransmit buffer list code (actually I removed all the code that call g_list_last in ice_send_thread, so also the code you mentioned earlier, to calculate number of bytes sent in last second). With it I spend 50% of time in ice_send_thread g_list_last. Without, perf results are really better, top function (srtp encryption function) doesn't go higher than 15%, and the rest is very low; and again this is with a quite heavy bitrate (aroud 6Mbps).
Il giorno venerdì 10 novembre 2017 10:39:31 UTC+1, Emmanuel Riou ha scritto:2017-11-10 10:19 GMT+01:00 Lorenzo Miniero <lmin...@gmail.com>:Il giorno venerdì 10 novembre 2017 10:07:18 UTC+1, Emmanuel Riou ha scritto:2017-11-10 3:30 GMT+01:00 Lorenzo Miniero <lmin...@gmail.com>:Thanks for digging more on this. I only see a couple of those instances: we use g_list_last to calculate how many bytes we sent in the last second (or whatever no_media_timer is set to), and g_list_append only to update the list of packets to retransmit. I guess the former could be redone without a list at all, not sure about the latter. Anyway, it's a GList, which means it's a double linked list: I'd expect a g_list_last or append to go ->prev from the head, instead of crawling the whole list the other way around.Hi Lorenzo,It's true it's a double linked list but unfortunately, as mentioned in glib documentation g_list_append/g_list_last don't work as we would expect:"g_list_append() has to traverse the entire list to find the end, which is inefficient when adding multiple elements. A common idiom to avoid the inefficiency is to useg_list_prepend()and reverse the list withg_list_reverse()when all elements have been added."Not sure how more efficient that would be: wouldn't g_list_reverse() have to traverse the whole list too, to invert all the ->next and ->prev pointers? It sounds easier and quicker to do g_list_prepend() and not reverse at all, but only make sure the head of the list is still the same it was before.g_list_reverse is not efficient either, but as mentioned in the documentation you do it only once, once the list is complete, which is not relevant for us. So yes g_list_prepend instead of g_list_append would be the solution.Yep, g_list_prepend plus making sure the head doesn't change (as I believe a prepend would make the prepended item the head instead).
Anyway, as a quick test you can try preventing the code to store the retransmitted packet at all, and see how much it improves for you: if it's considerable, we can think of better ways to do the same thing, e.g., using the method described above.I've done this test already, it is clearly really better without the retransmit buffer list code (actually I removed all the code that call g_list_last in ice_send_thread, so also the code you mentioned earlier, to calculate number of bytes sent in last second). With it I spend 50% of time in ice_send_thread g_list_last. Without, perf results are really better, top function (srtp encryption function) doesn't go higher than 15%, and the rest is very low; and again this is with a quite heavy bitrate (aroud 6Mbps).That's really interesting! Sorry, didn't know you had made these tests already, I thought you had only done profiling so far (well, *only*, that's a huge task already...).
I'm abroad until the 26th for various events and next week in particular I'll be very busy, so not sure when I'll be able to prepare a patch that includes what we discussed in this exchange. I'll notify here in case I manage to put something together quickly that you and others can test.Thanks again for this really useful feedback!
L.L.
L.
Cheers,Emmanuel.
To unsubscribe from this group and all its topics, send an email to meetech...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "meetecho-janus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meetecho-janus/8_XGmAnOv-4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meetech...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "meetecho-janus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meetecho-janus/8_XGmAnOv-4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meetech...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "meetecho-janus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meetecho-janus/8_XGmAnOv-4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meetech...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "meetecho-janus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meetecho-janus/8_XGmAnOv-4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meetech...@googlegroups.com.
You received this message because you are subscribed to the Google Groups "meetecho-janus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.
A.
To unsubscribe from this group and stop receiving emails from it, send an email to meetech...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "meetecho-janus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meetech...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/meetecho-janus/8ec7610b-614c-4736-9160-b22800fec5c3%40googlegroups.com.