Skip to content

Commit 506439b

Browse files
committed
fix(amazonq): use Dispatchers.IO for @workspace requests
Default dispatcher is limited on threads. Network requests should be under Dispatchers.IO
1 parent 19931e5 commit 506439b

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q: Attempt to reduce thread pool contention caused by `@workspace` makinng large number of requests"
4+
}

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/ProjectContextController.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent
1515
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
1616
import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
1717
import kotlinx.coroutines.CoroutineScope
18+
import kotlinx.coroutines.Dispatchers
1819
import kotlinx.coroutines.Job
1920
import kotlinx.coroutines.TimeoutCancellationException
2021
import kotlinx.coroutines.launch
@@ -28,7 +29,7 @@ class ProjectContextController(private val project: Project, private val cs: Cor
2829
// TODO: Ideally we should inject dependencies via constructor for easier testing, refer to how [TelemetryService] inject publisher and batcher
2930
private val encoderServer: EncoderServer = EncoderServer(project)
3031
private val projectContextProvider: ProjectContextProvider = ProjectContextProvider(project, encoderServer, cs)
31-
val initJob: Job = cs.launch {
32+
val initJob: Job = cs.launch(Dispatchers.IO) {
3233
encoderServer.downloadArtifactsAndStartServer()
3334
}
3435

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/ProjectContextProvider.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.intellij.openapi.vfs.VirtualFile
1616
import com.intellij.openapi.vfs.VirtualFileVisitor
1717
import com.intellij.openapi.vfs.isFile
1818
import kotlinx.coroutines.CoroutineScope
19+
import kotlinx.coroutines.Dispatchers
1920
import kotlinx.coroutines.async
2021
import kotlinx.coroutines.delay
2122
import kotlinx.coroutines.launch
@@ -44,7 +45,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
4445
private val mapper = jacksonObjectMapper()
4546

4647
init {
47-
cs.launch {
48+
cs.launch(Dispatchers.IO) {
4849
if (ApplicationManager.getApplication().isUnitTestMode) {
4950
return@launch
5051
}

0 commit comments

Comments
 (0)