What would optional memoization in grunt.file.expand mean for long-running build pipelines?
0 reputation · 01 Sept 2020, 12:04 UTC
Context
Grunt's grunt.file.expand and grunt.file.expandMapping currently perform synchronous filesystem reads on every invocation with no internal caching. This design avoids stale results but can impose repeated I/O overhead when the same patterns are evaluated multiple times during a single build.
Unresolved behavior
The Grunt codebase has not introduced optional memoization for these APIs, though the possibility has been discussed as a performance optimization for large file sets. If a future version added an opt-in cache layer, it would need to coexist with existing plugin-level watch caches (such as those in grunt-contrib-watch) that already manage their own invalidation strategies.
Goal
Understand the design constraints and invalidation requirements that would govern any optional memoization feature, so that build authors can anticipate whether such a change would reduce I/O without re-introducing the stale-file-list problems that currently only appear at the plugin layer.
What invalidation triggers would a core memoization layer need to respect? How would it interact with watch plugins that already maintain separate caches? Would the feature be scoped per-task, per-target, or per-process?