⚡ Optimize repeated repository tree fetching#81
Conversation
- Introduced a 5-minute cache for `get_repository_tree` using `DashMap`. - Prevents repeated API calls to GitLab for file tree, improving performance and reducing rate limit usage. - Added `src/tests/gitlab_cache_test.rs` to verify caching behavior. - Verified with existing tests and new cache test. Co-authored-by: myaple <10523487+myaple@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
⚡ Performance Improvement: Cache Repository Tree Fetching
💡 What
Implemented a caching mechanism for
get_repository_treein theGitlabApiClient. The cache usesDashMapfor thread-safe concurrent access and has a Time-To-Live (TTL) of 5 minutes.🎯 Why
The repository file tree was being fetched repeatedly (via
RepoContextExtractor::get_all_source_files) during context extraction for issues and merge requests. Since the file tree structure rarely changes drastically within a short period, repeated fetching was causing unnecessary latency and API rate limit consumption.📊 Measured Improvement
get_repository_treemade an API call (or multiple for pagination) every time it was invoked. Verified by testtest_get_repository_tree_cache_behaviorwhich initially expected 2 calls for 2 invocations.Implementation Details
repo_tree_cache: DashMap<i64, (Vec<String>, Instant)>toGitlabApiClient.GitlabApiClient::new.get_repository_treeto check cache before making request.src/tests/gitlab_cache_test.rscovering the caching logic.PR created automatically by Jules for task 3666510817023256830 started by @myaple