-
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
⚡ discover assets in parallel #4973
Conversation
Signed-off-by: Salim Afiune Maya <[email protected]>
Signed-off-by: Salim Afiune Maya <[email protected]>
This will help us submit as many requests as we want without knowing about the workers. Signed-off-by: Salim Afiune Maya <[email protected]>
Signed-off-by: Salim Afiune Maya <[email protected]>
35b1eff
to
f76eda1
Compare
Signed-off-by: Salim Afiune Maya <[email protected]>
f76eda1
to
8c98904
Compare
Signed-off-by: Salim Afiune Maya <[email protected]>
Signed-off-by: Salim Afiune Maya <[email protected]>
@@ -198,6 +198,18 @@ | |||
"shell", "ssh", "[email protected]", | |||
], | |||
}, | |||
{ | |||
"name": "scan github org", |
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.
did you mean to keep this in here
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.
Yes. I think it is useful for folks testing, specially now that we have https://github.com/hit-training.
I can remove it.
You can now run
I'll add a CI job for it. |
Signed-off-by: Salim Afiune Maya <[email protected]>
…el_asset_discovery Signed-off-by: Salim Afiune Maya <[email protected]>
8364872
to
e785c76
Compare
We really don't need to do everything inside the workerpool, do we? Signed-off-by: Salim Afiune Maya <[email protected]>
81de208
to
e3a58fd
Compare
Signed-off-by: Salim Afiune Maya <[email protected]>
@@ -92,7 +116,7 @@ func (p *Pool[R]) Close() { | |||
|
|||
// Wait waits until all tasks have been processed. | |||
func (p *Pool[R]) Wait() { | |||
ticker := time.NewTicker(100 * time.Millisecond) | |||
ticker := time.NewTicker(10 * time.Millisecond) |
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.
This fixed the benchmark failure.
@@ -74,6 +74,7 @@ func NewGithubConnection(id uint32, asset *inventory.Asset) (*GithubConnection, | |||
ctx := context.WithValue(context.Background(), github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true) | |||
|
|||
// perform a quick call to verify the token's validity. | |||
// @afiune do we need to validate the token for every connection? can this be a "once" operation? |
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.
This is fixed with #4980
providers/runtime.go
Outdated
r.Provider.Connection, r.Provider.ConnectionError = r.Provider.Instance.Plugin.Connect(req, &callbacks) | ||
r.mu.Unlock() |
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.
The problem is the assignation here, not the actual gRPC call Connect()
. I will change this.
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.
✅ updated
Signed-off-by: Salim Afiune Maya <[email protected]>
Signed-off-by: Salim Afiune Maya <[email protected]>
17495df
to
8badda7
Compare
Signed-off-by: Salim Afiune Maya <[email protected]>
Depends on #4970
This PR is using the new
workerpool
package to discover assets in parallel.There were a few places that I detected race conditions that I have fixed, I
also added a race detector
make
command which is running as a CI job.Testing
Using the
github
provider for testing, scanning an organization that has around 3k repositories.Before (~15 Minutes)
After (~2 minutes)
Race Detector
You can now run
make race/go
to check for race conditions.