Skip to content

Timestamp fingerprinting is slow for large glob patterns (e.g. **/*.gql) #2746

@ItaiYosephi

Description

@ItaiYosephi

Description

When using method: timestamp with glob patterns like **/*.gql that match thousands of files across a large directory tree, the fingerprinting step is significantly slower than expected (~6.6s for ~5000 matching files in a monorepo).

What did you do?

Created a task with method: timestamp and source globs like:

sources:
  - /path/to/monorepo/schema/**/*.gql
  - /path/to/monorepo/app/src/**/*.gql
  - /path/to/monorepo/app/scripts/codegen/**/*
generates:
  - /tmp/output.txt

What did you expect to happen?

The up-to-date check should be fast since it only needs to compare file modification times.

What happened instead?

The check takes ~6.6s because:

  1. Globs() uses execext.ExpandFields which shells out to expand glob patterns into a complete file list before any timestamp comparison. For **/*.gql patterns matching thousands of files, this is very expensive (~2.7s per call).

  2. Value() is called redundantly: In compiledTask() (variables.go:184), the Value() call is not gated by evaluateShVars. Since RunTask calls both FastCompiledTask and CompiledTask sequentially (task.go:142 and task.go:159), Value() runs twice — adding ~2.7s of unnecessary overhead.

  3. No short-circuiting in IsUpToDate: All globs are fully expanded into a file list before any timestamp comparison begins. For the common "up-to-date" case, this means stating every single matching file even though only one newer file would be enough to decide.

Version

Latest main (commit 54bdcba)

Operating system

macOS (Darwin 25.3.0), but the issue is platform-independent — it affects any large directory tree with ** glob patterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for support.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions