Repository navigation
perf(ldf): resolve each include name once per walk (FastLED incremental 25 s -> 7 s) - #1551
Merged
Merged
Conversation
…erence The header walker resolved every #include by is_file-probing each search path, for every reference, in each of the textual pre-walk and the LDF passes. With ESP32's ~400 search paths that was two thirds of the daemon's CPU on an incremental FastLED build (~17 s of 25 s). A name's search-path resolution does not depend on the including file, so WalkState now memoizes it per search-path list (quoted includes still check beside the including file first), and memoizes realpath. The defined-macro pre-walk shares the resolver, and its result is passed to the passes instead of being walked a second time. Refs #1539.
|
Warning Review limit reachedNext included review available in 52 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Repository: FastLED/fbuild/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
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. Comment |
zackees
added a commit
that referenced
this pull request
Sep 28, 2026
…ry path (#1554) 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.
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1539 and #1537. This is the dominant cost of every non-fast-path FastLED build, e.g. edit a sketch, rebuild.
Problem
fbuild_header_scan::walker::resolve_includeresolved each#includereference byis_file()-probing every search path in order. It did this for every reference in every file, in each of four walks per build:collect_defined_macro_namesran twice: once inresolve_with_stats_active_declared, then again insideresolve_with_stats_impl_declared, with identical inputs;ESP32 hands the LDF ~400 search paths (the SDK block, FastLED and the framework libraries), so an incremental FastLED build was millions of
statxcalls. Aperfprofile of the daemon during an incrementalDemoReel100build puts 67% of all samples underresolve_include → Path::is_file → statx.Fix (exact, memoization only)
WalkStategains anIncludeResolverbound to the search-path list, with two caches:visited/reached.WalkStateis used with a different search-path list.collect_defined_macro_names_with(seeds, paths, &mut state)runs the textual pre-walk on its own scan cache and visited set, since textual and active scanners must not mix. It shares the resolver, and its result is passed into the passes, so the second identical walk is gone.Numbers
FastLED DemoReel100, esp32s3, local 16-core box: edit the sketch, then rebuild.
Blink-sized projects barely change, since their LDF was already small.
Tests
w30: a cached search-path result never overrides a sibling quoted include (a/x.hbeside the file versusinc/x.hon the search path).w31: a resolver reused with a different search-path list resolves afresh.fbuild-header-scantests and allfbuild-library-selecttests (lib,perf_tdd) pass.