-
Notifications
You must be signed in to change notification settings - Fork 23
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
⚡ fetch org repositories in parallel #4970
Conversation
Signed-off-by: Salim Afiune Maya <[email protected]>
Signed-off-by: Salim Afiune Maya <[email protected]>
break | ||
} | ||
|
||
// send as many request as workers we have |
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 do we limit by number of workers? Doesn't this artificially throttle things
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.
Good point. Let me check that.
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.
@jaym I updated the PR
This will help us submit as many requests as we want without knowing about the workers. Signed-off-by: Salim Afiune Maya <[email protected]>
599b1bc
to
93ca08d
Compare
internal/workerpool/collector.go
Outdated
} | ||
|
||
func (c *collector[R]) RequestsRead() int64 { | ||
return c.requestsRead |
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 there might be a data race here on requestsRead
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.
internal/workerpool/pool.go
Outdated
|
||
// PendingRequests returns the number of pending requests. | ||
func (p *Pool[R]) PendingRequests() int64 { | ||
return p.requestsSent - p.collector.RequestsRead() |
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'm not really familiar with the atomics api in go, but i would expect some sort of synchronized read on requestsSent
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.
atomic helps to do thread safe operations, yes, I missed the read calls, they are now there! 🙌🏽
Signed-off-by: Salim Afiune Maya <[email protected]>
Used the data race detector from go to validate.
|
Introducing an internal go package called
workerpool
that we can use to send parallelrequests when needed.
⚡ For this change, I am making the fetching of repositories for an organization faster.
Tested this code with an organization that has around 3k repositories
Before (~2 Minutes)
After (~5 seconds)