-
Notifications
You must be signed in to change notification settings - Fork 79
Improvements Phase 1: Implement a simple executor service running all scans in parallel. #1575
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
base: master
Are you sure you want to change the base?
Conversation
| "Container Scanner", | ||
| () -> invokeContainerScanningWorkflow(scanIdsToWaitFor, codeLocationAccumulator, blackDuckRunData, projectNameVersion) | ||
| ); | ||
| scanFutures.add(CompletableFuture.runAsync(() -> { |
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.
There are a few recurring themes across most of the futures:
- each future takes care of a tool
- each tool already has some form of callback and we're wrapping these into yet another callback
- catch OperationException / throw RuntimeException
- each future names its thread to something that closely resembles the tool name
This could probably be changed to avoid some of the repetition. Maybe overload the runToolIfIncluded method to take a scanFutures list that takes care of 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.
Yeah, thats a good thought, I will give this a try.
| ); | ||
| scanFutures.add(CompletableFuture.runAsync(() -> { | ||
| try { | ||
| Thread.currentThread().setName("Binary Scan Thread"); |
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.
Should we reset the thread names to something else after the tools are done? Or is there no chance of thread reuse with incorrect names?
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, currently there is no chance of thread reuse since before invoking each future, we assign a thread name but I was planning to introduce a global counter in Phase 3 where will have weights assigned to each thread, so reuse is possible there.
This PR creates a simple executor service which takes in the value of parallel processors passed in
--detect.parallel.processorsproperty and then runs all tasks if the threads are empty.There are two parts where parallelization is done:
Most parallelization changes are in IntelligentModeStepRunner and ConcurrentScanWaiter class. Other changes are making the lists and sets thread safe that we use commonly between scans. Also logging for diagnostic zip has been updated to reflect thread name to make things clearer for users (The logs will remain dispersed but the thread name will clear the confusion).
As discussed in the grooming meeting, there is no weightage assigned to scan type currently, that will be implemented in Phase 3 of this improvement.