[bug] Search result hydration performs duplicate repository lookups within the same chunk
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
Hướng nghiên cứu
Bắt đầu trong packages/web/src/features/search/zoektSearcher.ts tại createReposMapForChunk, sau đó đọc phần thiết lập hiện có trong zoektSearcher.test.ts. Tái hiện trường hợp có 100 tệp dùng chung một repository_id và đếm số lần gọi mocked prisma.repo.findUnique. Được xem là hoàn tất khi chỉ có một lần tra cứu cho mỗi repository duy nhất trong một chunk, đồng thời vẫn giữ nguyên hành vi cache streaming hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When search returns multiple files from the same repository, createReposMapForChunk performs a separate Prisma repository lookup for each file.
The repository cache is checked inside concurrent Promise.all callbacks, but it is only populated after the database query resolves. Because of this, files from the same uncached repository all miss the cache and start duplicate lookups.
For example, I tested 100 search results from the same repository and observed 100 prisma.repo.findUnique calls instead of 1.
I would expect repository metadata to be fetched once per unique repository and reused for the other results.
This adds unnecessary database work to the search path, especially when many results come from the same repository.
To reproduce
Using the existing zoektSearcher.test.ts setup:
Return 100 files with the same repository_id.
Mock prisma.repo.findUnique and count the calls.
Run zoektSearch.
findUnique is called 100 times, even though all files belong to one repository.
I also tested two repositories:
100 files from 1 repository → 100 lookups
100 files split across 2 repositories → 100 lookups
For streaming search, the cache works across completed chunks. A second chunk containing files from an already cached repository makes 0 additional lookups. The duplicate lookups happen within the same chunk.
Sourcebot deployment information
Sourcebot version: Local development build from current main
Additional information
Relevant code:
packages/web/src/features/search/zoektSearcher.ts
Function:
createReposMapForChunk
The same search path is also used by Ask Sourcebot tools such as grep and glob.
I haven't measured the production latency impact, so the confirmed issue here is the redundant database work rather than a specific search latency regression.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.9k
- Fork
- 374
- Merge trung bình
- 21 giờ 18 phút
- Pull request đã merge (30 ngày)
- 39
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sourcebot-dev/sourcebot
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
sourcebot-dev/sourcebot#1633 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sourcebot-dev/sourcebot#1384 · 4 bình luận ·
-
ask_sb bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
sourcebot-dev/sourcebot#1137 · 4 bình luận ·
-
bug triage needed
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
sourcebot-dev/sourcebot#1661 · 1 bình luận ·
-
Feature
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
sourcebot-dev/sourcebot#1659 · 1 bình luận ·
Tất cả issue của sourcebot-dev/sourcebot
Issue tương tự
-
blocklist removal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
MetaMask/eth-phishing-detect#296544 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
pastelsky/bundlephobia#1122 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100