-
Notifications
You must be signed in to change notification settings - Fork 17
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
simplify and add DoNotWaitForStreamingResponses #75
Conversation
I removed the search value canceled context test since it was racy, it was racing the errCh. The new code waits for one worker to not error or all of them to error before resolving instead of leaking goroutines.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No code bugs identified here, mostly just concerns about the complexity and clarity of what's going on.
The potential bugs are associated with whether this design will really give us what we need in kubo (e.g. ipfs/kubo#10020 (comment)). In particular the non-generic parallel routers were pretty specific but were handling edge cases that compparallel
is having problems with. We can deal with that via leveraging the composability better, if the code in the consumer (e.g. kubo) ends up looking reasonable with this abstraction then 👍 otherwise it might need to change a bit to accommodate.
@@ -3,6 +3,7 @@ module github.com/libp2p/go-libp2p-routing-helpers | |||
go 1.19 | |||
|
|||
require ( | |||
github.com/Jorropo/jsync v1.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the value of using jsync here? The commit that introduces this claims it's a performance improvement due to not needing a goroutine that might be short lived, but AFAIK this code isn't really in the critical path anywhere which means it's just another abstraction reviewers have to keep in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo it makes the code more clear, easy as when it reaches 0 some code executes.
It's also limited to internal implementation and isn't exposed to consumers in anyway, jsync
just depends on the std so I think it's fine as-is.
errorsLk.Lock() | ||
if outCh == nil { | ||
outCh = make(chan T) | ||
errors = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this do anything other than let the GC collect a few bytes earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's used in the error handling:
if errors == nil {
return
}
errs = append(errs, err)
if errors is nil then it understand something else already had a sucessfull and it does not need to be appending.
errCh := make(chan error) | ||
var wg sync.WaitGroup | ||
var ready sync.Mutex | ||
ready.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think more explanation around the ready lock seems reasonable. Readers can follow the code, but with async code like this it's easy for anyone who comes next to miss something.
var minusOne uint64 | ||
minusOne-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we doing this with uints instead of ints?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it can't be negative.
850d18a
to
95ff051
Compare
Suggested version: Changes in (empty)
Cutting a Release (and modifying non-markdown files)This PR is modifying both Automatically created GitHub ReleaseA draft GitHub Release has been created. |
No description provided.