Skip to content

feat(channels): add named worker priorities with no memory growth - #5018

Merged
zackees merged 1 commit into
masterfrom
feat/named-worker-priority
Nov 4, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/named-worker-priority

Conversation

@zackees

@zackees zackees commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Adds fl::Priority::{Auto, High, Medium, Low} to FastLED.addLeds() after the existing core argument and to ChannelOptions::mWorker.priority. LCD/I2S Auto starts at High (23 on ESP32); Medium maps to 12 and Low to 1. Existing shared-worker inheritance, conflict rejection, and unsupported-driver rejection remain intact.

Default policies compile to a no-op, without driver singleton access or per-controller fields. WorkerConfig shrinks from 3 to 2 bytes. The scheduler mapping remains confined to the supported LCD backend. A redundant diagnostic-only argument was removed from the RMT allocation fallback helper to offset the small Xtensa linker-relaxation change; allocation behavior and diagnostics are preserved.

Matched default Blink measurements against f9beb26cee26d48a6d7213c1c1464f157a133754, with the same fbuild 2.5.51/toolchains:

Target Allocated image before → after Static RAM before → after
ESP32-S3 320259 → 320259 B 73384 → 73384 B
ESP32dev 287555 → 287555 B 23520 → 23520 B
Uno 3600 → 3600 B 118 → 118 B

Validation: 330/330 native unit groups and 95/95 examples passed under sanitizers; targeted LCD, slim-controller and RMT allocator groups passed; full lint passed. S3 AutoResearch compiled against the actual SDK with named High exercised through both APIs. Layout/default-path tests guard against configuration growth and lazy singleton allocation. Repository/pre-push review found no actionable issues.

The attached boards are ESP32dev and two C6s, so live S3 worker/wire validation is not claimed. Runtime numeric priority assignments must migrate to the enum (23 → fl::Priority::High). The existing addLeds/core template positions remain compatible.

Refs #5001. Details and reproducible measurements: agents/tasks/issue-5001-priority.md.

Summary by CodeRabbit

  • New Features
    • Added named Auto, High, Medium, and Low worker priorities to supported LED configuration options, including compile-time and runtime setup. Existing configurations retain automatic priority behavior.
    • Documented platform mappings and constraints for worker priorities.
  • Bug Fixes
    • Unsupported priority settings and conflicting changes to shared workers are rejected.
    • Explicit worker-core configurations now use high priority in the affected examples.

@zackees zackees added the ci-full Run the complete release-equivalent CI matrix on this PR SHA label Nov 4, 2026
@github-actions github-actions Bot removed the ci-full Run the complete release-equivalent CI matrix on this PR SHA label Nov 4, 2026
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PR adds named worker-priority policies to channel configuration and threads them through clockless and SPI controller APIs. ESP32 LCD workers resolve the policies to task priorities. Tests and documentation cover the new behavior. A separate RMT change derives a diagnostic word count inside the allocation failure helper.

Changes: Named worker priority

Layer / File(s) Summary
Priority policy and worker configuration
src/fl/channels/worker_config.h, src/fl/channels/worker_policy.h
WorkerConfig now uses Priority values Auto, High, Medium, and Low. Worker-policy templates accept priority-only settings and pass both core and priority to supported controllers.
Priority forwarding through addLeds
src/FastLED.h, src/fl/channels/slim_bridge_controller.h, src/fl/channels/slim_spi_bridge_controller.h, src/chipsets.h, src/fl/chipsets/*, examples/AutoResearch/*
Clockless and SPI addLeds overloads and worker-aware controller aliases now forward priority. The explicit-core example calls set High.
ESP32 LCD priority resolution
src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp.hpp
The LCD worker maps Auto and High to the default priority, Medium to half the available priority count, and Low to 1. It uses the resolved value for worker configuration and task creation.
Priority validation and documentation
tests/fl/channels/*, tests/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp, src/fl/channels/README.md, agents/tasks/*
Tests cover priority forwarding, controller size, worker acceptance, and ESP32 mappings. Documentation and task notes describe policy defaults, supported settings, measurements, and validation results.

RMT allocation diagnostic

Layer / File(s) Summary
Derive diagnostic word count
src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp, src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.h
handleAllocateTxFailure no longer accepts words_needed. It derives the value from mem_blocks when runtime logging is enabled.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CFastLED
  participant ClocklessWorkerController
  participant WorkerPolicy
  participant LCDClocklessDriver
  CFastLED->>ClocklessWorkerController: forward core and priority
  ClocklessWorkerController->>WorkerPolicy: apply worker policy
  WorkerPolicy->>LCDClocklessDriver: configure worker
  LCDClocklessDriver->>LCDClocklessDriver: resolve named priority for task
Loading

Possibly related issues

  • Issue 5001: This PR adds LCD worker priority selection, but does not add the core selection described in the issue.
  • Issue 2974: The PR changes the diagnostic argument handling in handleAllocateTxFailure, a function identified by the issue’s related sub-item. It does not move the formatting and logging machinery into a cold helper.

Possibly related PRs

  • FastLED/FastLED#5003: This PR changes the worker configuration interface and templates introduced by that PR.

Suggested labels: ci-platforms-unit-test, ci-platform:esp32dev

Merge Risk: Minimal · up to 2f0b4

No actionable merge-blocking issue is established. The change appears mergeable subject to normal build and test checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 24.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding named worker priorities while preserving memory usage.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 24.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 25 functions across 18 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f9beb26 and 2f0b411.

Files selected for processing: 22
  • agents/tasks/issue-5001-priority.md
  • agents/tasks/lessons.md
  • agents/tasks/todo.md
  • examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
  • examples/AutoResearch/LegacyClocklessProxy.h
  • src/FastLED.h
  • src/chipsets.h
  • src/fl/channels/README.md
  • src/fl/channels/slim_bridge_controller.h
  • src/fl/channels/slim_spi_bridge_controller.h
  • src/fl/channels/worker_config.h
  • src/fl/channels/worker_policy.h
  • src/fl/chipsets/fixed_rgbw_controller.h
  • src/fl/chipsets/ucs7604.h
  • src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/rmt_memory_manager.h
  • tests/fl/channels/channel.cpp
  • tests/fl/channels/slim_bridge_controller.cpp
  • tests/fl/channels/spi_channel.cpp
  • tests/fl/channels/worker_config.cpp
  • tests/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Memory usage (this PR vs. its merge base)

Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, 0 is unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (0) 136 (0)
esp32c3 324,198 ($\color{green}\downarrow$ 6) 13,770 (0)
esp32c6 354,066 (0) 17,877 (0)
esp32dev 287,555 (0) 18,651 (0)
esp32s3 320,291 (0) 22,451 (0)
esp8266 264,667 (0) 6,808 (0)
nrf52840_dk 68,048 (0) 19,468 (0)
rp2040 103,068 (0) 8,624 (0)
stm32f103c8 22,904 (0) 1,789 (0)
teensy41 47,104 (0) 21,738 (0)
uno 3,600 (0) 134 (0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant