Performance & Thermal Tuning.
Extract peak token generation speeds and maximize battery efficiency on Android. Learn how ARM DynamIQ CPU topology, memory-mapped I/O (mmap), thermal mitigation curves, and KV cache sizing prevent stalls and overheating.
Real-World Chipset Benchmarks (Q4_K_M)
Measured on production ARM64-v8a llama.cpp runtime under 22°C ambient room temperature with 4 performance threads:
| SoC / Processor | Tested Devices | 3B Model Speed | 7B Model Speed | Battery / 1k Tokens | Thermal Profile |
|---|---|---|---|---|---|
| Snapdragon 8 Gen 3 (Adreno 750 / Cortex-X4) | Galaxy S24 Ultra, OnePlus 12 | 42 – 55 tok/s | 18 – 24 tok/s | 0.8% – 1.1% | Excellent (Vapor Chamber keeps under 42°C) |
| Snapdragon 8 Gen 2 (Adreno 740 / Cortex-X3) | Galaxy S23, Nothing Phone 2 | 32 – 44 tok/s | 14 – 18 tok/s | 1.0% – 1.4% | Very Good (Stable 4-thread execution) |
| Google Tensor G3 / G4 (Mali-G715) | Pixel 8 Pro, Pixel 9 | 26 – 36 tok/s | 11 – 15 tok/s | 1.2% – 1.6% | Moderate (Throttle kicks in after 4 mins) |
| Dimensity 8020 / 7200 (Mid-Range) | Nothing Phone 2a, Redmi Note 13 Pro | 20 – 28 tok/s | 8 – 11 tok/s | 1.4% – 1.9% | Warm (Recommend 3B and 1.5B models) |
ARM big.LITTLE / DynamIQ CPU Topology & Thread Scheduling
Why setting your thread count equal to the number of Performance cores (typically 4) yields higher tokens per second and drastically reduced thermal dissipation compared to saturating all 8 virtual cores.
The Heterogeneous Cluster Problem: Thread Synchronization Stalls
Modern mobile SoCs (like Snapdragon 8 Gen 3, Dimensity 9300, and Google Tensor G4) organize CPU cores into heterogeneous clusters managed by ARM DynamIQ technology. A typical 8-core silicon floorplan divides as follows:
Cortex-X4 @ 3.3 GHz. Maximum IPC and wide NEON/SVE2 vector execution, but consumes high power per clock cycle.
Cortex-A720 @ 3.0 GHz. Optimized balance of high floating-point throughput, large L2 cache, and thermal efficiency.
Cortex-A510 / Cortex-A520 @ 2.0–2.2 GHz. Stripped-down in-order pipeline with narrow 64-bit vector units designed for background tasks.
Why Spawning 8 Threads Destroys Token Throughput:
In llama.cpp and GGML tensor runtimes, matrix multiplications (GEMM/GEMV) are partitioned into equal row slices across active worker threads. At the end of each tensor layer, all threads must synchronize at a pthread barrier:
- The Stalled Barrier: If you configure 8 threads, 2–4 threads are assigned to slow Cortex-A510/A520 efficiency cores. The fast Prime and Performance threads finish their row tile computation in ~4 milliseconds, but must then busy-wait or sleep for 18+ milliseconds waiting for the slow efficiency cores to complete their slice.
- Wasted Joules: The fast cores burn energy idling at the barrier while the efficiency cores operate near 100% capacity at low vector throughput, producing higher overall heat for lower net tokens/sec.
- The 4-Thread Golden Rule: Pinning Local AI to 4 threads confines all matrix math strictly to the Cortex-X prime and Cortex-A7xx performance cores. Work distribution finishes synchronously, eliminating thread barrier stalls and delivering 15% to 30% higher net token speed.
Memory-Mapped I/O (mmap) Deep Dive
How Linux kernel virtual memory page tables allow Local AI to load multi-gigabyte models in under 1.5 seconds without copying weights byte-by-byte into resident RAM.
- App allocates 3.8 GB of physical RAM heap via
malloc(). - App issues synchronous
read()system calls reading the entire GGUF file from UFS storage. - Startup Latency: 12 to 18 seconds before the first prompt can be entered.
- OOM Risk: Kernel treats every allocated page as dirty memory, triggering aggressive Android LMK SIGKILL if headroom drops.
- Kernel creates virtual memory area (VMA) mappings in the process page table pointing to GGUF disk offsets.
- Zero initial physical memory is consumed; weights are loaded on demand via minor page faults.
- Startup Latency: Under 1.5 seconds to ready state.
- Zero Swap Thrash: File-backed clean pages can be discarded instantly by the kernel if another app needs RAM, avoiding crash kills.
Virtual Address Space (VIRT) vs Resident Set Size (RSS)
When you monitor Local AI in Android Studio Profiler or ADB, you will observe the process VIRT (Virtual Memory) size immediately jump to ~4.5 GB, while RSS (Resident Set Size) remains small. As tokens are generated, only the specific weight matrices currently involved in attention projection and feed-forward layers are paged into physical RAM. This allows the OS page cache to intelligently prioritize active tensors.
Thermal Throttling Curves & Mitigation Techniques
Smartphones dissipate heat through passive conduction into the aluminum frame and vapor chambers. Understanding CPU junction temperatures prevents performance cliffs.
The 4 Stages of the Mobile Thermal Throttle Curve
Thick silicone, leather, or rugged polycarbonate phone cases trap radiant heat, causing CPU junction temperatures to reach the 80°C throttle limit 3.5× faster than an unencased phone.
Fast charging (30W–120W) generates substantial thermal heat inside the battery pack. Combining fast charging with LLM matrix multiplication instantly trips Stage 3/4 throttling.
Restricting execution to 4 performance threads limits the total SoC power draw to 4.5W–6W, allowing the phone vapor chamber to stabilize indefinitely at Stage 2 without dropping off the performance cliff.
Context Window KV Cache RAM Sizing Table
The Key-Value (KV) cache stores past token attention states in physical memory. Memory consumption scales strictly linearly with context length. Plan your token budget to prevent Android Low Memory Killer (LMK) terminations:
| Model Parameter Tier | 2k Context (Standard) | 4k Context | 8k Context | 16k Context | Safe Minimum Device RAM |
|---|---|---|---|---|---|
| 1.5B Parameters (e.g. Qwen 2.5 1.5B) | 140 MB | 280 MB | 560 MB | 1.12 GB | 4 GB RAM devices |
| 3B Parameters (e.g. Llama 3.2 3B) | 250 MB | 500 MB | 1.00 GB | 2.00 GB | 6 GB – 8 GB RAM devices |
| 7B – 8B Parameters (e.g. Qwen 2.5 7B, Llama 3.1 8B) | 520 MB | 1.04 GB | 2.08 GB | 4.16 GB | 12 GB+ RAM devices |
| 14B Parameters (e.g. Qwen 2.5 14B Q4) | 980 MB | 1.96 GB | 3.92 GB | 7.84 GB | 16 GB+ Workstations / Flagships |
* Note: KV cache figures assume FP16 precision. When using Q8_0 or Q4_0 quantized KV cache (available in Local AI advanced developer settings), memory footprint is reduced by 50% to 75% respectively, allowing higher context limits on 6GB/8GB devices.
Performance, Thermal & Cache FAQs
Why is setting 4 threads faster and cooler than setting 8 threads on Android?+
What does memory-mapped I/O (mmap) do in Local AI?+
How does CPU thermal throttling affect token generation speed?+
How much memory does the Key-Value (KV) cache consume at 8k or 16k context?+
How much battery does generating 1,000 words actually consume?+
Does fast internal flash storage (UFS 4.0 vs UFS 2.2) affect token speed?+
Download Local AI for Android
Equipped with hardware-aware thread allocation, memory-mapped storage, and Smart RAM protection.