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.
This commit is contained in:
Jinwei Han 2026-04-19 23:49:25 -07:00
parent fc674574ca
commit 72e57ec4e7
2 changed files with 2 additions and 2 deletions

View File

@ -51,7 +51,7 @@ public class CpuInfo {
private int getHighPerfCpuCountByVariant() {
List<Integer> 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)

View File

@ -26,7 +26,7 @@ private class CpuInfo(private val lines: List<String>) {
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<Int>.binnedValues() = groupingBy { it }.eachCount()