fix(autofix): Prevent long wait times for insights threadpool at end of run #1631
+1,582
−379
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #1630
I discovered in profiling that when the root cause step completed, there was sometimes a huge wait (the case I saw was 6 seconds) for the thread pool to finish it's last insight card generation, before moving onto the root cause formatter. (similar for the coding step)
Why? Because we started a new insight sharing thread after every LLM call, including the final call of the agent run. Due to Zach's changes that make us wait for threads to complete before ending the run, this caused big delays.
Solutions in this PR:
We could completely eliminate this delay if we didn't wait for the threads to be completed, and I'm not sure that's a bad idea, but I'm still assuming we don't want to sacrifice that safety. This PR mitigates most of the issue while maintaining thread safety.