Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit fb6bdf34 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

perf: drop signature concurrency cap

Remove the semaphore limit so signature checks can run fully in parallel for faster matching.
parent 84a1faca
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@ import foundation.e.apps.domain.preferences.AppPreferencesRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.util.Locale
@@ -64,8 +62,6 @@ class UpdatesManagerImpl @Inject constructor(
        private const val MILLIS_IN_SECOND = 1000L
        private const val SECONDS_IN_MINUTE = 60L
        private const val MINUTES_IN_HOUR = 60L

        private const val SIGNATURE_CONCURRENCY = 4
    }

    private val userApplications: List<ApplicationInfo>
@@ -369,17 +365,14 @@ class UpdatesManagerImpl @Inject constructor(
            installedPackageNames.size
        )
        val appsAndSignatures = hashMapOf<String, String>()
        val semaphore = Semaphore(SIGNATURE_CONCURRENCY)
        val candidates = installedPackageNames.map { packageName ->
            async {
                semaphore.withPermit {
                val perPackageStartMs = nowMs()
                val signature = updateAppsWithPGPSignature(packageName, cleanApkAppsByPackage)
                val duration = formatDuration(nowMs() - perPackageStartMs)
                Triple(packageName, signature, duration)
            }
        }
        }

        candidates.forEach { deferred ->
            val (packageName, signature, duration) = deferred.await()