Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lincheck benchmarks #250

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open

Lincheck benchmarks #250

wants to merge 25 commits into from

Conversation

eupp
Copy link
Collaborator

@eupp eupp commented Nov 20, 2023

This PR adds benchmarking infrastructure to the Lincheck. It includes:

  • API to track progress of lincheck test run: LincheckRunTracker interface.
  • Statistics gathering infrastructure based on LincheckRunTracker API.
  • New gradle tasks to run benchmarks (tests and benchmarks are put into separate source sets).
  • Several benchmarks for standard concurrent data structures and synchronization primitives.
  • Script to draw various plots based on collected benchmark statistics (using Lets-Plot Kotlin library).

@eupp eupp requested a review from ndkoval November 20, 2023 18:57
@ndkoval ndkoval linked an issue Jan 18, 2024 that may be closed by this pull request
class SequentialRendezvousIntChannelSpecification : SequentialIntChannelSpecification(capacity = 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to rename it? It causes a lot of unrelated changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can revert this.

@@ -25,8 +25,8 @@ class ThreadDumpTest {
repeat(iterations) {
val options = StressOptions()
.minimizeFailedScenario(false)
.iterations(100_000)
.invocationsPerIteration(1)
.iterations(10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, without this the CI do not pass, but fails with OOM.
With this change, the memory usage (according to TC) is roughly the same as on develop branch.

@@ -38,8 +38,10 @@ abstract class CTestConfiguration(
val customScenarios: List<ExecutionScenario>
) {
abstract fun createStrategy(
testClass: Class<*>, scenario: ExecutionScenario, validationFunction: Actor?,
stateRepresentationMethod: Method?, verifier: Verifier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of not passing a verifier instance in the constructor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code for checking invocation result was duplicated in stress and managed strategies.
Once I refactored to be the extension function of Strategy class, there is no longer a need to pass the verifier in the constructor, since it effectively becomes unused by the concrete Strategy implementers.


@ExperimentalCoroutinesApi
@InternalCoroutinesApi
@Param(name = "value", gen = IntGen::class, conf = "1:5")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What line exactly do you mean?
The @Param annotation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @Param could be removed, yes.

fun get(): Int = lock.withLock { counter }
}

class IntrinsicLockBenchmark : AbstractLincheckBenchmark() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SynchronizedBenchmark?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will rename

import org.jetbrains.kotlinx.lincheck_benchmark.AbstractLincheckBenchmark
import java.util.concurrent.ConcurrentHashMap

@Param(name = "key", gen = IntGen::class, conf = "1:5")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need it?

import org.jetbrains.kotlinx.lincheck_benchmark.AbstractLincheckBenchmark
import java.util.concurrent.*

@Param(name = "value", gen = IntGen::class, conf = "1:5")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need it?

import org.jetbrains.kotlinx.lincheck_benchmark.AbstractLincheckBenchmark

@InternalCoroutinesApi
@Param(name = "value", gen = IntGen::class, conf = "1:5")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need it?

}
}

class ReentrantLockBenchmark : AbstractLincheckBenchmark() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this benchmark? It does not look realistic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took it from lincheck tests.
There were tests for several kinds of locks: spin locks, intrinsic locks (synchronized), and re-entrant lock objects.

I just changed the lock-protected data structure from set to counter. Because I think the exact data structure used under lock is not relevant for these benchmarks, so I picked the simplest one possible. If you have arguments why we should use sets as an underlying data structure, I will be ready to revert it to sets.

@@ -44,19 +42,11 @@ class StressStrategy(
}
}

override fun run(): LincheckFailure? {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this refactoring (and the one in ManagedStrategy) in a separate PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: #262

eupp added 22 commits May 30, 2024 13:46
Signed-off-by: Evgeniy Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgeniy Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgeniy Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
…shboards

Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
* rewrite .txt report file on each run
* compute average invocation time in case of per-iteration granularity
* do not draw error-bars if standard-error is not computed

Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
- do not reuse verifier for minimization

Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
…r tests

Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgenii Moiseenko <evg.moiseenko94@gmail.com>
eupp added 3 commits June 10, 2024 13:05
Signed-off-by: Evgeniy Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgeniy Moiseenko <evg.moiseenko94@gmail.com>
Signed-off-by: Evgeniy Moiseenko <evg.moiseenko94@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create real-world benchmarks
2 participants