perf(git): implement batch file lookup via git diff-tree --stdin#62
Open
c-ferrier wants to merge 1 commit into
Open
perf(git): implement batch file lookup via git diff-tree --stdin#62c-ferrier wants to merge 1 commit into
c-ferrier wants to merge 1 commit into
Conversation
Optimizes the atom parsing phase by replacing sequential 'git diff-tree' process spawns with a single bulk retrieval using 'git diff-tree --stdin'. This reduces OS process overhead and leverages Git's internal caches, resulting in a ~30x speedup for file list lookups during history scans. Standardizes the IGitClient interface to a 'Batch-by-Default' design (array-based getFilesChanged) to enforce high-performance patterns. Hardens the batch parser by whitelisting requested hashes to prevent misidentification of hexadecimal file paths. Lore-id: 3918a757 Constraint: IGitClient.getFilesChanged MUST only accept string arrays Constraint: Batch parser MUST whitelist requested hashes Constraint: GitClient MUST use --stdin for bulk lookups Tested: Verified ~33x speedup with internal performance benchmark Tested: All 427 unit tests passing including new robust GitClient suite Tested: Verified type-safety with npm run typecheck across all call sites Tested: Manually verified parsing accuracy with sneaky-path scenarios Confidence: high Scope-risk: narrow Reversibility: clean Assisted-by: Gemini:CLI [lore-protocol]
b912b7c to
427490f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a high-performance batching strategy for retrieving file lists during the atom parsing phase.
Summary of Change:
Replaces sequential 'git diff-tree' process spawns with a single bulk retrieval using 'git diff-tree --stdin'. This drastically reduces OS process overhead and allows Git to leverage its internal caches more effectively.
Performance Impact (Cache Miss Optimization):
In our benchmarks on this repository (~29 atoms), we observed a ~10% reduction in total command time for 'lore log --json'.
While the percentage seems small in this repo, the savings are O(N) where N is the number of Lore atoms. In a large repository with 500+ atoms, this converts a multi-second 'hang' into a sub-100ms operation.
Relationship with Atom Cache:
This is primarily a Cache Miss Optimization.
The 'atom-cache' remains faster for cache hits (~63ms in benchmarks), so having both features provides the ideal performance profile: fast hydration followed by near-instant subsequent reads.