Conversation with Gemini

You said

What tools are there to debug poor mobile phone performance? My Xiaomi Redmi Note 13 is glacially slow, even after a complete reset to defaults.

Gemini said

When a phone remains painfully slow immediately after a factory reset, the issue is almost always a low-level bottleneck: aggressive thermal throttling, hardware degradation (flash storage wear), background service loops, or OS-level configurations like swap-to-disk overhead.

Tools and methods to diagnose and trace poor performance on a Xiaomi device (HyperOS / MIUI) range from quick settings fixes to deep system profiling tools.

1. Quick Xiaomi-Specific Diagnostics & Fixes

Before diving into command-line profiling, check these common MIUI/HyperOS settings that frequently degrade performance on mid-range hardware:

  • Disable "Memory Extension" (Virtual RAM):

    • Where: SettingsAdditional SettingsMemory Extension → Set to Off.

    • Why: Virtual RAM uses internal storage (UFS/eMMC) as swap memory. Storage write speed is orders of magnitude slower than physical RAM. On a fresh reset, this feature often turns back on by default and throttles system responsiveness.

  • Access the Hardware Diagnostic Menu (CIT):

    • How: Open the Phone dialer and type *#*#6484#*#* (or go to SettingsAbout PhoneDetailed info and specs → tap Kernel version 5 times).

    • Use: Tests onboard sensors, thermal sensors, and flash storage responsiveness.

2. On-Device Profiling Tools (Developer Options)

Enable Developer Options by going to SettingsAbout Phone and tapping OS Version / MIUI Version 7 times.

System Tracing (Perfetto Frontend)

Android includes a native system trace recorder built into the Developer Options.

  • Where: SettingsDeveloper OptionsSystem Tracing.

  • How to use:

    1. Turn on Trace debuggable apps and select categories (CPU frequency, scheduling, memory, graphics).

    2. Tap Record trace.

    3. Reproduce the stutter/lag (e.g., opening settings, scrolling) for 10–15 seconds, then stop the trace.

  • Analysis: Pull the .pftrace file from /data/misc/perfetto-traces/ using ADB or a file manager and open it on ui.perfetto.dev. It shows exact CPU frequencies, kernel context switches, and thread bottlenecks.

Profile HWUI Rendering

  • Where: SettingsDeveloper OptionsProfile HWUI Rendering → Choose On screen as bars.

  • How it helps: Displays real-time rendering performance on your screen. Any bar spiking above the green line (16ms for 60Hz or 8.3ms for 120Hz) indicates a dropped frame and pinpoints whether lag is UI thread/GPU-bound.

3. Deep System Debugging via ADB (PC Connected)

Connecting your phone to a computer with adb installed provides the clearest picture of what is slowing the system down.

A. Spot CPU Hogs & Rogue Daemons

Check if a background service or corrupt system app is pinning the CPU in an infinite loop:

Bash
adb shell top -m 10 -s cpu
  • Look at CPU consumption percentage while the phone is idling. If process names like system_server, surfaceflinger, or Xiaomi telemetry services stay constantly high (>20-30%), you've found the issue.

B. Inspect Memory Pressure & Throttling

Bash
adb shell dumpsys cpuinfo
adb shell dumpsys meminfo
  • dumpsys cpuinfo shows average load over time.

  • dumpsys meminfo shows how physical RAM is allocated and if the system is under heavy memory pressure (zRAM thrashing).

C. Check Thermal Throttling

If a thermal sensor is failing or reporting incorrect values, the kernel will cap CPU frequencies to minimum levels to prevent damage.

Bash
adb shell dumpsys thermal
  • Inspect the thermal zones. If status is marked as MODERATE, SEVERE, or CRITICAL while the device feels cold to the touch, a hardware sensor glitch is forcing CPU throttling.

D. Capture System Logcat Errors

A system service continuously crashing and restarting in the background causes severe UI lag:

Bash
adb logcat *:E
  • If error messages stream rapidly without stopping, identify the package name causing the log spam.

4. Hardware Storage Wear Checks

If a phone remains slow post-reset, degraded flash memory (high write wear causing slow I/O) is a prime candidate.

Via ADB, check flash health stats (if accessible by the kernel build):

Bash
adb shell cat /sys/class/block/mmcblk0/device/life_time
# or for UFS storage:
adb shell "cat /sys/kernel/debug/*.ufs/health" 2>/dev/null
  • Value outputs like 0x01 indicate 0-10% life used. If it reads 0x0A (90-100% life used) or higher, the onboard flash storage is worn out and throttling disk writes.

You said

How do I install adb on a computer?

Gemini said

To install ADB (Android Debug Bridge), you don't need to install full software like Android Studio—you just need Google's official SDK Platform-Tools package.

Choose your operating system below.

Windows

Method 1: Portable Binary (No installation required)

1
Download Platform Tools
Official Google zip file

Download the standalone SDK Platform-Tools for Windows directly from the Android Developer Website.

2
Extract the Zip Archive

Extract the downloaded .zip file to an accessible location on your drive (e.g., C:\platform-tools).

3
Open Terminal in the Directory

Open the platform-tools folder. Hold Shift and right-click in any empty space inside the folder, then select Open PowerShell window here or Open in Terminal.

4
Verify ADB Connection

Type the following command to start the ADB daemon:

DOS
.\adb devices

(Note: The .\ prefix is required in PowerShell if the directory is not added to your system PATH).

Method 2: Package Manager (Automated System-Wide Installation)

If you use a Windows package manager, you can install ADB system-wide without manually managing ZIP archives or environment variables:

  • Winget:

    DOS
    winget install Google.PlatformTools
    
  • Chocolatey:

    DOS
    choco install adb
    

macOS

Method 1: Homebrew (Recommended)

If you have Homebrew installed, open Terminal and run:

Bash
brew install android-platform-tools

This installs adb globally, allowing you to run adb devices from any terminal directory.

Method 2: Manual Zip

  1. Download SDK Platform-Tools for Mac from Google.

  2. Extract the .zip to your preferred folder (e.g., ~/platform-tools).

  3. Open Terminal, navigate to the directory:

    Bash
    cd ~/platform-tools
    
  4. Run ADB using ./adb:

    Bash
    ./adb devices
    

Linux

Package Manager (Debian / Ubuntu / Fedora / Arch)

Most distributions package ADB in their official repositories:

  • Debian / Ubuntu / Mint:

    Bash
    sudo apt update
    sudo apt install android-tools-adb android-tools-fastboot
    
  • Fedora / RHEL:

    Bash
    sudo dnf install android-tools
    
  • Arch Linux / Manjaro:

    Bash
    sudo pacman -S android-tools
    

Preparing Your Phone

To allow your computer to communicate with your phone via ADB:

  1. On your Android device, go to Settings → About Phone and tap Build Number (or OS Version) 7 times to unlock Developer Options.

  2. Go to Settings → System → Developer Options (or Additional Settings → Developer Options).

  3. Toggle USB Debugging to On.

  4. Connect the phone to your computer via USB.

  5. When you run adb devices for the first time, check your phone screen and tap Always allow from this computer on the RSA authorization prompt.

Next steps to trace your device performance:
You said

And FreeBSD?

Gemini said

On FreeBSD, ADB is available directly through the official ports tree and package repository via the consolidated devel/android-tools port.

1. Installation

Via Binary Package (pkg)

Bash
pkg install android-tools

Via Ports Tree

If you build from source:

Bash
cd /usr/ports/devel/android-tools/ && make install clean

(This package includes adb, fastboot, and related utilities like mkbootimg.)

2. Setting Up USB Permissions (devfs)

By default, non-root users cannot access raw USB endpoints (/dev/ugen*). To run adb without needing sudo or root:

  1. Add your user to the operator group:

    Bash
    pw groupmod operator -m your_username
    
  2. Configure /etc/devfs.rules to allow access: If /etc/devfs.rules doesn't exist, create it and add a rule for USB access:

    Ini, TOML
    [localrules=10]
    add path 'ugen*' mode 0660 group operator
    add path 'usb/*' mode 0660 group operator
    add path 'usbctl' mode 0660 group operator
    
  3. Enable the ruleset in /etc/rc.conf:

    Ini, TOML
    devfs_system_ruleset="localrules"
    
  4. Restart devfs to apply:

    Bash
    service devfs restart
    

3. Running ADB

Once installed and devfs permissions are set, plug in the phone with USB debugging enabled on the device, then start the daemon:

Bash
adb devices

If you encounter permissions issues, restarting the daemon with elevated privileges will confirm if it's a devfs ownership issue:

Bash
adb kill-server
sudo adb devices
profile picture


Gemini is AI and can make mistakes.