Skip to content

walker: sniff shebangs only in extensionless files#5

Merged
alyx merged 1 commit into
mainfrom
perf/shebang-policy
Jul 12, 2026
Merged

walker: sniff shebangs only in extensionless files#5
alyx merged 1 commit into
mainfrom
perf/shebang-policy

Conversation

@alyx

@alyx alyx commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Stacked on the traversal PR (top of the stack; reject-able independently). This is the one intentional behavior change from the audit — everything in the other three PRs is byte-identical.

aloc currently opens and reads every file whose extension it doesn't recognize, hunting for a shebang — ~13k wasted opens on the Linux kernel tree (.lock, .dts, config fragments, …). tokei and scc only sniff extensionless files. This PR adopts that policy via a sniffable helper:

  • extensionless (script, Makefile.d/foo → no ext) → sniffed, as before
  • unrecognized extension (run.xyz) → skipped without any syscall, same unknown language trace
  • dotfiles: .bashrc is extensionless (one leading dot stripped, matching Rust Path::extension, hence tokei); file. (bare trailing dot) still sniffs

Behavior change: a shebang script with an unrecognized extension (e.g. run.xyz starting with #!/usr/bin/env python3) is no longer detected or counted. README updated; walker tests pin the full policy table end-to-end.

Measured: on a corpus with ~17% unknown-extension files: wall −22% (1.168s → 0.91s mean, interleaved). On trees without such files: zero output change — verified byte-identical (including --by-file) on the 52k corpus AND Linux 6.9; the 400 extensionless bin/tool* shebang scripts in the corpus are all still counted. The single intended diff was demonstrated on a purpose-built tree: exactly one file (run.xyz) drops.

🤖 Generated with Claude Code

@alyx
alyx changed the base branch from perf/traversal-micro to main July 12, 2026 16:24
@alyx
alyx merged commit 71eda1d into main Jul 12, 2026
1 check passed
@alyx
alyx deleted the perf/shebang-policy branch July 12, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant