Add additional thread delete performance improvements.

This commit is contained in:
Cody Henthorne
2026-03-06 12:10:54 -05:00
committed by jeffrey-signal
parent b0b2c32a6f
commit 02ce6c62a8
8 changed files with 161 additions and 18 deletions

View File

@@ -51,6 +51,7 @@ object BenchmarkMetrics {
val threadDeletion: List<TraceSectionMetric>
get() = listOf(
TraceSectionMetric("ThreadTable#deleteConversations", Mode.Sum),
TraceSectionMetric("MessageTable#deleteMessagesInThread", Mode.Sum)
TraceSectionMetric("MessageTable#deleteMessagesInThread", Mode.Sum),
TraceSectionMetric("deleteMessages", Mode.Sum)
)
}

View File

@@ -8,8 +8,11 @@ object BenchmarkSetup {
private const val TARGET_PACKAGE = "org.thoughtcrime.securesms.benchmark"
private const val RECEIVER = "org.signal.benchmark.BenchmarkCommandReceiver"
fun setup(type: String, device: UiDevice, timeout: Long = 25_000L) {
device.executeShellCommand("pm clear $TARGET_PACKAGE")
fun setup(type: String, device: UiDevice, timeout: Long = 25_000L, clearData: Boolean = true) {
if (clearData) {
device.executeShellCommand("pm clear $TARGET_PACKAGE")
}
device.executeShellCommand("am start -W -n $TARGET_PACKAGE/org.signal.benchmark.BenchmarkSetupActivity --es setup-type $type")
device.wait(Until.hasObject(By.textContains("done")), timeout)
}

View File

@@ -12,6 +12,7 @@ import androidx.benchmark.macro.junit4.MacrobenchmarkRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -73,4 +74,26 @@ class ThreadDeletionBenchmarks {
device.wait(Until.gone(By.textContains("Title")), 300_000L)
}
}
@Ignore("Needs locally provided backup file not available in CI yet")
@Test
fun deleteGroupThread20kMessagesWithBackupRestore() {
benchmarkRule.measureRepeated(
packageName = "org.thoughtcrime.securesms.benchmark",
metrics = BenchmarkMetrics.threadDeletion,
iterations = 1,
compilationMode = CompilationMode.Partial(),
setupBlock = {
BenchmarkSetup.setup("backup-restore", device, timeout = 60_000L)
killProcess()
startActivityAndWait()
device.waitForIdle()
device.wait(Until.findObject(By.textContains("CuQ75j")), 10_000)
}
) {
BenchmarkSetup.deleteThread(device)
device.wait(Until.gone(By.textContains("CuQ75j")), 300_000L)
}
}
}