Skip to content

Commit 64b1e18

Browse files
authored
Usvm competitions 2024: jacodb persistence (#2703)
* Use jacodb persistence * Update usvm version
1 parent c2d693b commit 64b1e18

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jakartaVersion=3.1.0
104104
jacoDbVersion=1.4.1
105105
# TODO left outdated here to avoid exceeding GitHub packages drive space,
106106
# TODO run `gradle publishToMavenLocal -Pversion={usvmVersion}` locally in usvm project and update {usvmVersion} locally
107-
usvmVersion=comp-231128-22
107+
usvmVersion=comp-231129-22
108108

109109
# use latest Java 8 compaitable Spring and Spring Boot versions
110110
springVersion=5.3.28

utbot-junit-contest/src/main/kotlin/org/utbot/contest/usvm/ContestUsvm.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.jacodb.approximation.Approximations
1212
import org.jacodb.impl.features.InMemoryHierarchy
1313
import org.objectweb.asm.Type
1414
import org.usvm.PathSelectionStrategy
15+
import org.usvm.PathSelectorFairnessStrategy
1516
import org.usvm.SolverType
1617
import org.usvm.UMachineOptions
1718
import org.usvm.api.targets.JcTarget
@@ -85,12 +86,14 @@ fun runUsvmGeneration(
8586

8687
val jcContainer by lazy {
8788
JcContainer(
89+
usePersistence = true,
8890
classpath = classpathFiles,
8991
machineOptions = UMachineOptions(
9092
// TODO usvm-sbft: if we have less than CONTEST_TEST_EXECUTION_TIMEOUT time left, we should try execute
9193
// with smaller timeout, but instrumentation currently doesn't allow to change timeout for individual runs
9294
timeout = generationTimeoutMillisWithoutCodegen.milliseconds - CONTEST_TEST_EXECUTION_TIMEOUT,
9395
pathSelectionStrategies = listOf(PathSelectionStrategy.CLOSEST_TO_UNCOVERED_RANDOM),
96+
pathSelectorFairnessStrategy = PathSelectorFairnessStrategy.COMPLETELY_FAIR,
9497
solverType = SolverType.YICES,
9598
)
9699
) {

utbot-junit-contest/src/main/kotlin/org/utbot/contest/usvm/jc/JcContainer.kt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ private val logger = KotlinLogging.logger {}
1919

2020
// TODO usvm-sbft-refactoring: copied from `usvm/usvm-jvm/test`, extract this class back to USVM project
2121
class JcContainer private constructor(
22+
usePersistence: Boolean,
2223
classpath: List<File>,
2324
machineOptions: UMachineOptions,
2425
builder: JcSettings.() -> Unit,
@@ -29,8 +30,27 @@ class JcContainer private constructor(
2930
val runner: UTestConcreteExecutor
3031

3132
init {
33+
val cpPath = classpath.map { it.absolutePath }.sorted()
34+
35+
/**
36+
* Persist jacodb cp to achieve:
37+
* 1. Faster concrete executor initialization
38+
* 2. Faster analysis for classes from the same cp
39+
* */
40+
val persistenceLocation = if (usePersistence) {
41+
"jcdb-persistence-${cpPath.hashCode()}"
42+
} else {
43+
null
44+
}
45+
3246
val (db, cp) = runBlocking {
33-
val db = jacodb(builder)
47+
val db = jacodb {
48+
builder()
49+
50+
if (persistenceLocation != null) {
51+
persistent(location = persistenceLocation, clearOnStart = false)
52+
}
53+
}
3454
val cp = db.classpathWithApproximations(classpath, listOf(UnknownClasses))
3555
db to cp
3656
}
@@ -39,8 +59,9 @@ class JcContainer private constructor(
3959
this.machine = JcMachine(cp, machineOptions)
4060
this.runner = UTestConcreteExecutor(
4161
JcRuntimeTraceInstrumenterFactory::class,
42-
classpath.map { it.absolutePath },
62+
cpPath,
4363
cp,
64+
persistenceLocation,
4465
CONTEST_TEST_EXECUTION_TIMEOUT
4566
)
4667
runBlocking {
@@ -61,6 +82,7 @@ class JcContainer private constructor(
6182
private val cache = HashMap<Pair<List<File>, UMachineOptions>, JcContainer>()
6283

6384
operator fun invoke(
85+
usePersistence: Boolean,
6486
classpath: List<File>,
6587
machineOptions: UMachineOptions,
6688
builder: JcSettings.() -> Unit,
@@ -70,7 +92,7 @@ class JcContainer private constructor(
7092
// TODO usvm-sbft: right now max cache size is 1, do we need to increase it?
7193
logger.info { "JcContainer cache miss" }
7294
close()
73-
JcContainer(classpath, machineOptions, builder).also { cache[cacheKey] = it }
95+
JcContainer(usePersistence, classpath, machineOptions, builder).also { cache[cacheKey] = it }
7496
}
7597
}
7698

0 commit comments

Comments
 (0)