Repository navigation
Description
Context
Two investigation rounds at 94dab9c for #5024; no builds or timing measurements. Default BitbangPin::delay<CYCLES> (src/platforms/shared/spi_bitbang/bitbang_pin.h:37-39) calls fl::delaycycles<CYCLES>(). The visible public header (src/fl/system/delay.h:71) only declares that function; definitions/specializations live in src/fl/system/delay.cpp.hpp:53-150. This is a cross-translation-unit tiny-delay call unless toolchain optimization proves otherwise. The SPI writer invokes it from high/low macros at generic_software_spi.h:195-198.
ESP8266 already overrides this policy: src/platforms/esp/8266/fastpin_esp8266.h:173-185 explicitly documents avoiding three CALL/RET sequences per bit and uses global inline ::delaycycles for small counts, bounded counter wait for larger counts. That exception does not fix the default. Platform dispatch for inline templates exists in src/platforms/delaycycles.h:20-53.
Proposal
Make the shared default software-SPI tiny delay use a definition visible for inlining at the callsite, respecting platform dispatch and cycle accounting. Keep long delays bounded in code size; do not force unbounded NOP expansion on small-flash targets. Platform-specific overrides remain where real write-time/counter semantics require them.
Acceptance criteria
- Produce RED target disassembly from actual default-policy GenericSoftwareSPIOutput entry points showing tiny-delay calls; demonstrate GREEN without these calls after implementation for representative default-policy ARM, AVR and CI13XX target builds. Coordinate exact boards with sibling children and include no-LTO configurations so LTO is not the only evidence. Targets whose emitted code is already optimal should be classified with artifacts, not claimed improved.
- Production edge traces cover minimum pulse, half-period underflow boundaries, zero/negative padding, short and long requested delays, scalar/bulk/pixel/start-bit paths and multiple CPU clocks. Preserve hardware write cost and interrupt-time accounting; native test arithmetic alone does not prove nanoseconds.
- Record actual vendor board compilation, flash/code-size bounds at slow rates and relevant interrupt constraints. Compare baseline/new generated instruction sequences. Any physical speed claim needs measured device evidence via AutoResearch/fbuild.
- Restore the old default call as a mutation: focused generated-code check must fail, then pass after restoration. Marking a trait true or modifying a fixture/ledger without executing the default production path cannot pass.
Decisions
- One child for the shared default implementation, not one per instantiation; platform children own target-specific MMIO policies.
- ESP8266 is existing prior art and a regression case, including GPIO16 RTC exception, rather than another newly invented generic capability.
- Duplicate metadata search
BitbangPinreturned only parent perf: audit and accelerate software SPI across all platforms #5024. Shared validation is tracked separately as a prerequisite.
Open questions
The exact generated cost depends on compiler/LTO and platform definitions; establish the focused failing target repro before choosing an implementation. No physical speedup is asserted by this source audit.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(spi): inline bounded default delays and retain target probes
zackees commentedon Nov 6, 2026
Blocked, not started. Real CI13xx builds need fbuild 2.5.52 (native CI1306 support from FastLED/fbuild#1914, release prepared in FastLED/fbuild#1920). PyPI and GitHub still show 2.5.51 as the latest, so these acceptance builds cannot run yet, and FastLED has no ci13xx board entry until the floor is raised. Skipping ahead in #5024 until that release exists.
perf(spi): inline the default software-SPI tiny delay at the callsite (…