add timeout to requests and optimize directory traversal #151
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.
Performance Optimization: Early Skipping of Excluded Directories
This update introduces an optimization in the repository traversal logic to improve performance by avoiding unnecessary processing of excluded directories.
Problem
Previously, directories that matched an exclusion pattern (e.g.,
vendor/
,node_modules/
,dist/
) were still being entered and traversed. Although their files were later excluded, this resulted in:This behavior led to performance degradation, especially in repositories with large dependency or build directories.
Performance Before Optimization
The application spent significant time processing excluded directories, even when they contained hundreds or thousands of irrelevant files:
Solution
The new implementation introduces a pre-check that evaluates whether a directory matches any exclude pattern before entering it. If a match is found, the traversal skips that directory entirely, eliminating further file reads and API calls within it.
Performance After Optimization
With early exclusion applied, the processing time and API calls were significantly reduced:
Summary of Changes
requests.get()
calls to handle network instability more robustly.This optimization enhances both performance and scalability, particularly when analyzing large repositories.