Skip to content

fix: apply the git recency boost to file priority; compile priority regexes once - #274

Open
SahibYar wants to merge 4 commits into
prooflinedev:mainfrom
SahibYar:fix/apply-git-recency-boost
Open

SahibYar wants to merge 4 commits into
prooflinedev:mainfrom
SahibYar:fix/apply-git-recency-boost

Conversation

@SahibYar

@SahibYar SahibYar commented Nov 29, 2026 •

Copy link
Copy Markdown

Fixes #272
Fixes #273

Summary

#272: the Git recency boost never affected priority. Three independent defects, each of which disabled it on its own:

Defect Fix
process_files_parallel ignored the boost map (_boost_map) and built the processor with empty commit_times ParallelFileProcessor::with_recentness_boost applies it. Keys are canonical absolute paths, so yek src/ matches the repo-root-relative paths git reports
get_recent_commit_times_git2 walked each commit's full tree, so every file in HEAD got HEAD's time and all boosts tied at 0 Diff each commit against its first parent; the newest commit that touches a path decides its time
clap-config-file ignores default_value on config-only scalars, so max_git_depth was 0 on the CLI and the revwalk did take(0) apply_config_scalar_defaults restores DEFAULT_MAX_GIT_DEPTH (100) unless the config sets max_git_depth / max-git-depth; an explicit 0 is still respected

A follow-up commit also drops files whose newest change was a deletion. Before, the older commit that added such a file gave it a time, which widened the range the boost is normalised over.

#273: regexes compiled per file. CompiledPriorityRules is built once per processor and reused for every file. get_file_priority and get_file_priority_with_category keep their public signatures and delegate to it.

Results

Running yek on this repo, the src/ files committed most recently (config.rs, error.rs, pipeline.rs) now come last. Before, the order was alphabetical.

Priority-rule benchmark, 20,000 files, 10 rules, release build, 5 runs each:

wall time
before ~2.3 s
after ~0.19 s

Output is byte-for-byte identical (cmp).

CI fix included

The Benchmark and Code Coverage jobs failed on this PR, and on other fork PRs such as #269 and #271, before running any yek code:

  • They ran git checkout ${{ github.head_ref }}, but a fork's branch doesn't exist in this repo: error: pathspec 'fix/apply-git-recency-boost' did not match.
  • git fetch origin main resolved to the tag main (194c765, v0.21.0) rather than the branch, so benchmark and coverage baselines were measured against old code.

ci: check out PR and base commits by SHA switches both jobs to github.event.pull_request.base.sha and github.sha. Happy to split this into its own PR if you prefer.

Notes for review

  • One commit per concern, each green on its own.
  • src/config.rs is near the code fix: read snake_case keys from yek config files #269 touches (snake_case config keys), so a small rebase may be needed depending on merge order. The new default helper accepts both key styles, consistent with apply_config_bool_overrides.
  • Behaviour change: files not modified within the last max_git_depth commits now get no recency entry (boost 0). Before, they inherited HEAD's time.

Test plan

  • tests/git_boost_test.rs (new): newer file outranks older by exactly git_boost_max; subdirectory input; git_boost_max = 0; non-git directory; CLI end-to-end with no config. All failed before the fix.
  • priority_test: commit time is when the file last changed, not HEAD (failed before)
  • priority_test: modified files take the newer time; deleted files are dropped (failed before the follow-up); files outside the max_git_depth window are left out
  • config.rs unit tests: max_git_depth default without a config file, default when the key is omitted, and explicit values in both key styles
  • priority_test: CompiledPriorityRules sums matches, skips invalid patterns, and matches get_file_priority
  • cargo test --no-fail-fast: 414 passed, 0 failed
  • make lint (clippy -D warnings + fmt --check)
  • Coverage job reproduced locally with grcov: base 81.48% → PR 82.35%. 160/163 changed executable lines are covered; the 3 uncovered lines are the diff_tree_to_tree error branch, which only runs on a corrupt object database
  • Windows: the Stress job runs the built binary on this repository (a git checkout) on x86_64-pc-windows-msvc, so the boost path runs there

The recency boost never changed file priority or output order. Three
defects each disabled it on its own:

- serialize_repo computed the boost map but process_files_parallel
  ignored it (`_boost_map`), and the processor was built with empty
  commit_times. The processor now takes the boost map, keyed by
  canonical absolute path so subdirectory inputs match the repo-root
  paths git reports.
- get_recent_commit_times_git2 walked the full tree of each commit, so
  every file in HEAD got HEAD's time and all boosts were 0. Each commit
  is now diffed against its first parent, so a file only gets the time
  of a commit that changed it.
- clap-config-file ignores default_value on config-only scalars, so
  max_git_depth was 0 on the CLI and no commits were scanned. It now
  falls back to DEFAULT_MAX_GIT_DEPTH (100) unless the config sets it.

Fixes prooflinedev#272
get_file_priority compiled every rule's regex on each call, and the
parallel processor called it once per file, so a run did files x rules
regex compilations. Add CompiledPriorityRules, built once when the
processor is created, and score every file against it.
get_file_priority and get_file_priority_with_category keep their
signatures and delegate to it.

20,000 files with 10 rules (release build, 5 runs): ~2.3s -> ~0.19s.
Output is byte-for-byte identical.

Fixes prooflinedev#273
A file deleted in a newer commit was skipped there, then picked up again
from the older commit that added it. Deleted paths stayed in the map and
widened the oldest/newest range that the recency boost is normalised
over. The newest commit touching a path now decides its entry, and a
deletion records no time.

Also cover modifications and the max_git_depth commit window.

Refs prooflinedev#272
The benchmark and coverage jobs ran `git checkout ${{ github.head_ref }}`.
For pull requests from forks that branch does not exist in this
repository, so both jobs failed with "pathspec did not match".

`git fetch origin main` also resolved to the tag named `main` (an old
v0.21 commit) instead of the branch, so baselines were measured against
the wrong code. Check out github.event.pull_request.base.sha and
github.sha instead, which are unambiguous and work for forks.

This branch has not been deployed

No deployments
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.

Priority rule regexes are recompiled for every file Git recency boost (git_boost_max) never affects file priority

1 participant