Skip to content

perf(runner): cache data-provider lookup per file#767

Merged
Chemaclass merged 1 commit into
mainfrom
perf/763-data-provider-cache
Jul 11, 2026
Merged

perf(runner): cache data-provider lookup per file#767
Chemaclass merged 1 commit into
mainfrom
perf/763-data-provider-cache

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #763

Every test paid a grep -B2 | sed fork just to check whether it had a @data_provider annotation, re-reading the file from disk once per test. The scan is identical for every function in a file, so it only needs to happen once.

💡 Changes

  • Scan each file's provider annotations once into a memoized fn -> provider map; per-test lookups are now pure-bash (no fork). Same single scan removes the per-test capture fork in both the run path and the test-counting path.
  • Fork census on a 100-test file: grep 202 -> 2, sed 300 -> 100, awk ~1 per file (memoization confirmed, not per-test); ~14% faster wall-clock (load-variable). Win is platform-independent, unlike the clock work.
  • Behaviour preserved: full suite 1218 -> 1225 (exactly the 7 new provider-map tests), green sequential and --parallel. A dropped total would have signalled missed detection. get_provider_data retained as a public wrapper over the new map.
  • Repo-wide shfmt drift (v3.13.1 vs the version the tree was formatted with) was left untouched; the added code shows no drift and there is no shfmt CI gate.

Scan each test file's @data_provider annotations once into a memoized
fn->provider map and replace the per-test grep+sed probe with a pure-bash
lookup. Also short-circuit the provider-data capture fork for the common
no-provider case, in both the run path and the test-counting path.

No behaviour change. Closes #763.
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 11, 2026
@Chemaclass Chemaclass self-assigned this Jul 11, 2026
@Chemaclass Chemaclass merged commit d62c7d8 into main Jul 11, 2026
31 checks passed
@Chemaclass Chemaclass deleted the perf/763-data-provider-cache branch July 11, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants