Skip to content

⚡ Optimize repeated repository tree fetching#81

Merged
myaple merged 1 commit intomainfrom
perf-optimize-repo-tree-fetching-3666510817023256830
Feb 15, 2026
Merged

⚡ Optimize repeated repository tree fetching#81
myaple merged 1 commit intomainfrom
perf-optimize-repo-tree-fetching-3666510817023256830

Conversation

@myaple
Copy link
Owner

@myaple myaple commented Feb 15, 2026

⚡ Performance Improvement: Cache Repository Tree Fetching

💡 What

Implemented a caching mechanism for get_repository_tree in the GitlabApiClient. The cache uses DashMap for 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

  • Baseline: get_repository_tree made an API call (or multiple for pagination) every time it was invoked. Verified by test test_get_repository_tree_cache_behavior which initially expected 2 calls for 2 invocations.
  • Optimization: With the cache, subsequent calls within the 5-minute window return the cached file list instantly without hitting the GitLab API. Verified by updating the test to expect only 1 API call for 2 invocations.

Implementation Details

  • Added repo_tree_cache: DashMap<i64, (Vec<String>, Instant)> to GitlabApiClient.
  • Initialized cache in GitlabApiClient::new.
  • Updated get_repository_tree to check cache before making request.
  • Added src/tests/gitlab_cache_test.rs covering the caching logic.

PR created automatically by Jules for task 3666510817023256830 started by @myaple

- 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>
@google-labs-jules
Copy link
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@myaple myaple merged commit 58f5684 into main Feb 15, 2026
3 checks passed
@myaple myaple deleted the perf-optimize-repo-tree-fetching-3666510817023256830 branch February 15, 2026 10:19
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