io.shiftleft.utils

Type members

Classlikes

For the Shiftleft SAAS offering, we are using non-inherited thread-local MDC (message diagnostic context) in order to relate log messages to artifacts. The same JVM process is concurrently processing multiple customer artifacts.

For the Shiftleft SAAS offering, we are using non-inherited thread-local MDC (message diagnostic context) in order to relate log messages to artifacts. The same JVM process is concurrently processing multiple customer artifacts.

In order to make this work, every long-running analysis gets its own MDCAwareExecutor, i.e. its own threadpool.

So all multi-threading in codepropertygraph must make sure to either:

  1. Code that uses new Thread must set up MDC correctly. For example, consider the Writer background-threads spawned in ParallelCpgPass.scala, or consider the background-threads spawned in overflowdb. 2. Code that directly (or scala-implicitly) uses threadpools / scala-style executors / java-style ExecutorService should call e.g. implicit val ec:ExecutionContextExecutor = io.shiftleft.utils.ExecutionContextProvider.getExecutionContext instead of implicit val ec:ExecutionContextExecutor = scala.concurrent.ExecutionContext.global or import scala.concurrent.ExecutionContext.Implicits 3. Code that uses java parallel stream (e.g. ForkJoinParallelCpgPass) needs no changes -- the java stream standard library automatically picks up the right threadpool that sets up MDC correctly.
object IOUtils

Finds the relative location of the project root.

Finds the relative location of the project root.

Used in tests which rely on the working directory - unfortunately Intellij and sbt have different default working directories for executing tests from subprojects: while sbt defaults to the project root, intellij defaults to the subproject.

Previously a consistent behaviour was achieved by setting Test / baseDirectory := (ThisBuild / Test / run / baseDirectory).value, however that broke the bsp build within Intellij - it simply wouldn't recognise subprojects with this setting any more.

Interface for deduplicating strings used by CPGLoader. JVM with G1 GC does this automatically but it is not guaranteed to happen and when performing CPU heavy calculations doing this manually ensures that we won't run out of memory.

Interface for deduplicating strings used by CPGLoader. JVM with G1 GC does this automatically but it is not guaranteed to happen and when performing CPU heavy calculations doing this manually ensures that we won't run out of memory.

Companion
object
Companion
class