Skip to content

Commit

Permalink
improvment: Limit number of read semanticdb files
Browse files Browse the repository at this point in the history
It seems in some scenarios it might read too much into memory and go OOM
  • Loading branch information
tgodzik committed Oct 18, 2024
1 parent 16ff008 commit 0eddfd2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package scala.meta.internal.metals

import java.util
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executors
import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.atomic.AtomicReference

import scala.concurrent.ExecutionContext
import scala.concurrent.ExecutionContextExecutorService
import scala.concurrent.Future
import scala.util.Failure
Expand Down Expand Up @@ -74,6 +76,8 @@ class ProjectMetalsLspService(
maxScalaCliServers,
) {

private val SemanticdbExecutionContext =
ExecutionContext.fromExecutor(Executors.newFixedThreadPool(10))
import serverInputs._

protected val buildTools: BuildTools = new BuildTools(
Expand Down Expand Up @@ -415,7 +419,7 @@ class ProjectMetalsLspService(
onChange(List(path)).asJava
} else if (path.isSemanticdb) {
val semanticdbPath = SemanticdbPath(path)
Future {
def changeSemanticdb = {
event.eventType match {
case EventType.Delete =>
semanticDBIndexer.onDelete(semanticdbPath)
Expand All @@ -424,7 +428,8 @@ class ProjectMetalsLspService(
case EventType.Overflow =>
semanticDBIndexer.onOverflow(semanticdbPath)
}
}.asJava
}
Future(changeSemanticdb)(SemanticdbExecutionContext).asJava
} else {
CompletableFuture.completedFuture(())
}
Expand Down

0 comments on commit 0eddfd2

Please sign in to comment.