-
Notifications
You must be signed in to change notification settings - Fork 54
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
bug: yamux Futures leak #1165
Comments
I'll summarize here what we discussed in private about this issue: We can reproduce the problem with the following code (compiling with import chronos
when defined(chronosFutureTracking):
proc dumpChronosInfo() {.async.} =
while true:
echo "\n----------- Dumping Chronos Info -----------"
echo dumpPendingFutures(OnlyPending)
await sleepAsync(1.seconds)
asyncSpawn dumpChronosInfo()
proc main() {.async.} =
while true:
discard await race(sleepAsync(50.millis()), sleepAsync(10.seconds()))
waitFor(main()) #1171 will fix it. It's probably not a perfect solution. #1175 could help make it better. |
@lchenut thank you for the summary. |
When running tests on nwaku and activating dumpPendingFutures from
nim-chronos
, we noticed that the pending futures grow indefinitely inyamux
.Most of them come from the following line
nim-libp2p/libp2p/muxers/yamux/yamux.nim
Lines 282 to 283 in a60f0c5
For example
I see these Futures get created at a really fast pace, and not seeing them getting completed. Even if they do eventually get completed, if we create futures at a faster rate than what it takes to complete them, the pending futures would grow indefinitely.
When using
mplex
instead, the amount of pending Futures is stable and doesn't grow indefinitelyVersion: nim-libp2p 94d93cb
Attaching logs with prints of the pending Futures for both
yamux
andmplex
logs_yamux.txt
logs_mplex.txt
The text was updated successfully, but these errors were encountered: