Skip to content

Commit 1bcbc9b

Browse files
committed
Adjust resource requirement for starting workspace indexing
1 parent ca39f32 commit 1bcbc9b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
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" : "Adjust resource requirement for starting workspace indexing"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/startup/AmazonQStartupActivity.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class AmazonQStartupActivity : ProjectActivity {
6363
}
6464

6565
private suspend fun startLsp(project: Project) {
66-
// Automatically start the project context LSP after some delay when average CPU load is below 30%.
66+
// Automatically start the project context LSP after some delay when average CPU load is below 40%.
6767
// The CPU load requirement is to avoid competing with native JetBrains indexing and other CPU expensive OS processes
6868
// In the future we will decouple LSP start and indexing start to let LSP perform other tasks.
6969
val startLspIndexingDuration = Duration.ofMinutes(30)
@@ -73,18 +73,19 @@ class AmazonQStartupActivity : ProjectActivity {
7373
withTimeout(startLspIndexingDuration) {
7474
while (true) {
7575
val cpuUsage = ManagementFactory.getOperatingSystemMXBean().systemLoadAverage
76-
if (cpuUsage > 0 && cpuUsage < 30) {
76+
if (cpuUsage > 0 && cpuUsage < 40) {
7777
ProjectContextController.getInstance(project = project)
7878
break
7979
} else {
80+
LOG.warn { "Current CPU usage is $cpuUsage, waiting for it to be below 40% to start LSP server" }
8081
delay(60_000) // Wait for 60 seconds
8182
}
8283
}
8384
}
8485
} catch (e: TimeoutCancellationException) {
85-
LOG.warn { "Failed to start LSP server due to time out" }
86+
LOG.warn { "Failed to start LSP server due to not enough resource" }
8687
} catch (e: Exception) {
87-
LOG.warn { "Failed to start LSP server" }
88+
LOG.warn { "Failed to start LSP server ${e.message}" }
8889
}
8990
}
9091

0 commit comments

Comments
 (0)