Skip to content

perf(ldf): index search-path roots so include misses stop probing every path - #1554

Merged
zackees merged 1 commit into
mainfrom
perf/ldf-defined-names-parallel
Sep 28, 2026
Merged

zackees merged 1 commit into
mainfrom
perf/ldf-defined-names-parallel

Conversation

@zackees

@zackees zackees commented Sep 28, 2026

Copy link
Copy Markdown
Member

Follow-up to #1551. Refs #1539 and #1537.

Problem

After #1551, each unique include name is resolved once per walk, but a name that no search path holds still costs one is_file per search path. With ESP32's ~400 search paths and FastLED's many platform-conditional includes (<avr/...>, platforms/arm/..., …), IncludeResolver::resolve was still about 15% of daemon CPU on an incremental FastLED build, and library selection took ~1.2 s.

Fix (exact)

  • On its first miss, the resolver read_dirs every search root once and builds a map from first path component to search-path indices, in search order. A name is probed only in paths whose root lists its first component. Candidates are confirmed with is_file() in order, so the first match is the probe loop's.
  • Keys fold case. That only widens the candidate set, so a case-insensitive filesystem's Foo.h/foo.h behaves as before.
  • These fall back to the full probe loop: names with ./../empty components, absolute names or backslashes, and a root that exists but can't be listed. A missing root is skipped, exactly as probing it would be.
  • The #define collection over reached files runs in parallel with rayon, like the walk's own reads.

Numbers

FastLED DemoReel100, esp32s3, incremental sketch edit (library archives → selection logged):

library selection
before #1551 ~17 s
after #1551 1.23–1.30 s
this PR 0.23 s

The same libraries are selected: FS, I2S, LittleFS, SPI, WiFi. The whole incremental build is now 6.0–7.5 s, dominated by the link.

Tests

  • w32: first component present in several roots, first holder wins, search order kept.
  • w33: sub/../up.h still resolves.
  • w34: a missing search path is skipped.
  • All 69 fbuild-header-scan tests and the fbuild-library-select suites pass.

…ry path

After #1551 each unique include name was resolved once, but a name no
search path holds (FastLED's many platform-conditional includes) still
cost one stat per search path -- ~400 on ESP32. The resolver now lists
each search root once and only probes the paths whose root holds the
name's first component, in search order; names with ./.. or absolute
paths, and unlistable roots, keep the full probe loop. Keys fold case,
which only widens the candidates each is_file() then confirms.

The defined-macro scan over reached files is parallel too.

Refs #1539.
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: FastLED/fbuild/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 2e2ef85d-3187-43f5-b744-3996fc9f4de3

📥 Commits

Reviewing files that changed from the base of the PR and between 5634455 and 76b8ecf.

📒 Files selected for processing (1)
  • crates/fbuild-header-scan/src/walker.rs

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

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant