From 72e57ec4e755f9d076ed86f081389ed632e809b1 Mon Sep 17 00:00:00 2001 From: Jinwei Han Date: Sun, 19 Apr 2026 23:49:25 -0700 Subject: [PATCH] android : fix CPU variant fallback returning LITTLE cluster count The variant fallback in getHighPerfCpuCountByVariant() used countKeepingMin() while the primary frequency branch used countDroppingMin(). Both branches are meant to return the count of high-performance cores, so the asymmetry caused the variant branch to return the LITTLE cluster count instead. On big.LITTLE SoCs, when cpuinfo_max_freq is unreadable and the code falls back to CPU variant (verified by the reporter on Helio G85 in ggml-org/whisper.cpp#3602), whisper ends up running on the LITTLE cores and inference throughput roughly halves. Fix mirrors the suggestion in the issue: use countDroppingMin() in the variant branch, matching the frequency branch. Both the Kotlin (whisper.android) and Java (whisper.android.java) examples share the same asymmetry and are fixed together. --- .../app/src/main/java/com/whispercpp/java/whisper/CpuInfo.java | 2 +- .../src/main/java/com/whispercpp/whisper/WhisperCpuConfig.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/whisper.android.java/app/src/main/java/com/whispercpp/java/whisper/CpuInfo.java b/examples/whisper.android.java/app/src/main/java/com/whispercpp/java/whisper/CpuInfo.java index 733ca354..de54fef6 100644 --- a/examples/whisper.android.java/app/src/main/java/com/whispercpp/java/whisper/CpuInfo.java +++ b/examples/whisper.android.java/app/src/main/java/com/whispercpp/java/whisper/CpuInfo.java @@ -51,7 +51,7 @@ public class CpuInfo { private int getHighPerfCpuCountByVariant() { List variants = getCpuValues("CPU variant", line -> Integer.parseInt(line.trim().substring(line.indexOf("0x") + 2), 16)); Log.d(LOG_TAG, "Binned cpu variants (variant, count): " + binnedValues(variants)); - return countKeepingMin(variants); + return countDroppingMin(variants); } @RequiresApi(api = Build.VERSION_CODES.N) diff --git a/examples/whisper.android/lib/src/main/java/com/whispercpp/whisper/WhisperCpuConfig.kt b/examples/whisper.android/lib/src/main/java/com/whispercpp/whisper/WhisperCpuConfig.kt index edfb415f..a579e52d 100644 --- a/examples/whisper.android/lib/src/main/java/com/whispercpp/whisper/WhisperCpuConfig.kt +++ b/examples/whisper.android/lib/src/main/java/com/whispercpp/whisper/WhisperCpuConfig.kt @@ -26,7 +26,7 @@ private class CpuInfo(private val lines: List) { private fun getHighPerfCpuCountByVariant(): Int = getCpuValues(property = "CPU variant") { it.substringAfter("0x").toInt(radix = 16) } .also { Log.d(LOG_TAG, "Binned cpu variants (variant, count): ${it.binnedValues()}") } - .countKeepingMin() + .countDroppingMin() private fun List.binnedValues() = groupingBy { it }.eachCount()