esp32·adblocker·rebornsimd & memory study

Empirical analysis of the Xtensa LX7 vector unit (PIE) vs. Octal PSRAM memory bus constraints.

Executive Summary

Question asked: Can the ESP32-S3 vector extensions (Xtensa LX7 128-bit SIMD instructions) meaningfully accelerate the DNS blocklist lookup and merge pipeline?

Finding: No. Every kernel touching the large domain arrays is strictly bound by Octal PSRAM bus bandwidth, not ALU execution width. Benchmarks demonstrate that 128-bit SIMD loads from PSRAM measure identically to scalar 32-bit loads. A wider ALU cannot accelerate a kernel stalled on external memory buses.

Benchmark: Throughput by Load Width (OCT PSRAM vs. IRAM)

Empirical throughput in MB/s on ESP32-S3 at 240 MHz CPU, 32 KB DCache, tested across memory domains:

Load / Copy MethodIRAM → IRAMPSRAM → IRAMPSRAM → PSRAM
8-bit scalar loop45.8 MB/s29.4 MB/s19.5 MB/s
32-bit scalar loop228.9 MB/s58.1 MB/s21.2 MB/s
64-bit scalar loop305.1 MB/s56.8 MB/s21.2 MB/s
Standard libc memcpy366.0 MB/s56.8 MB/s21.2 MB/s
PIE 128-bit SIMD (16 B/iter)1,207.6 MB/s58.1 MB/s21.1 MB/s
PIE 128-bit SIMD (32 B/iter)1,829.8 MB/s58.1 MB/s21.1 MB/s
Espressif dsps_memcpy_aes31,444.9 MB/s57.6 MB/s21.0 MB/s

Observation: Inside internal SRAM/IRAM, 128-bit SIMD provides a massive 5× speedup (366 → 1,830 MB/s). But when reading from external PSRAM, scalar 32-bit, libc, and 128-bit SIMD all plateau between 56.8 and 58.1 MB/s. Quadrupling load width yields zero throughput increase once data resides behind the MSPI cache.

Memory Cost Model

Measurements show that a single 32-byte cache line miss from PSRAM consumes:

True Architectural Optimizations

Because ALU widening does not address the bus bottleneck, performance was maximized through memory reduction:

  1. Bucket-Split Indexing: Shrunk entries from 4 bytes to 3 bytes, reducing total PSRAM footprint to fit 800,000+ domains into ~2.6 MB.
  2. L2 Fast Path: Bypasses lwIP and socket layers entirely, saving ~40 μs of kernel stack overhead.
  3. Direct Suffix Walks: Early-exit termination on bare TLDs (e.g. .com) eliminating redundant binary search probes.