You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I utilize the pion/dtls package which imports pion/transport for a private project. I noticed some scaling issues with my service and upon running pprof I noticed a lot of garbage collection activity related to the deadline package within this repo. This is due to updating the deadline on a DTLS connection via the pion/dtlsSetReadDeadline() method on every packet (we receive upwards of 50kpps on my service) so as you can imagine we are hitting that function call a lot as means of detecting dead DTLS connections.
Some output from pprof showing most of the allocated memory and objects come from deadline.Set() which uses time.After() which as currently implemented doesn't release the underlying timer to the garbage collector until it fires (we use a deadline of about 20 seconds).
time.After 's documentation states that The underlying Timer is not recovered by the garbage collector until the timer fires. If efficiency is a concern, use NewTimer instead and call Timer.Stop if the timer is no longer needed.
A useful blog post explaining a very similar to problem to the one I hit can be found here
I think moving towards using timer.NewTimer() directly would be more efficient (though I have currently worked around this via other means).
What did you expect?
Calling deadline.Set() should efficiently release unused memory to the garbage collector.
What happened?
My service that indirectly imports pion/transport spent too much time in garbage collection as a result of calling deadline.Set() at a high rate.
The text was updated successfully, but these errors were encountered:
Your environment.
What did you do?
I utilize the
pion/dtls
package which importspion/transport
for a private project. I noticed some scaling issues with my service and upon running pprof I noticed a lot of garbage collection activity related to the deadline package within this repo. This is due to updating the deadline on a DTLS connection via thepion/dtls
SetReadDeadline()
method on every packet (we receive upwards of 50kpps on my service) so as you can imagine we are hitting that function call a lot as means of detecting dead DTLS connections.Some output from pprof showing most of the allocated memory and objects come from
deadline.Set()
which usestime.After()
which as currently implemented doesn't release the underlying timer to the garbage collector until it fires (we use a deadline of about 20 seconds).time.After
's documentation states thatThe underlying Timer is not recovered by the garbage collector until the timer fires. If efficiency is a concern, use NewTimer instead and call Timer.Stop if the timer is no longer needed.
A useful blog post explaining a very similar to problem to the one I hit can be found here
I think moving towards using
timer.NewTimer()
directly would be more efficient (though I have currently worked around this via other means).What did you expect?
Calling
deadline.Set()
should efficiently release unused memory to the garbage collector.What happened?
My service that indirectly imports
pion/transport
spent too much time in garbage collection as a result of callingdeadline.Set()
at a high rate.The text was updated successfully, but these errors were encountered: