[bug] Search result hydration performs duplicate repository lookups within the same chunk
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
調査の方向性
packages/web/src/features/search/zoektSearcher.ts の createReposMapForChunk から始め、続いて既存の zoektSearcher.test.ts のセットアップを読みます。同じ repository_id を共有する 100 個のファイルのケースを再現し、mocked prisma.repo.findUnique の呼び出し回数を数えます。完了条件は、1 つの chunk 内の一意な repository ごとに 1 回だけ lookup が行われ、既存のストリーミングキャッシュの動作が維持されることです。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 3.9k
- フォーク
- 374
- 平均マージ
- 21時間 18分
- マージ済み PR(30日)
- 39
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sourcebot-dev/sourcebot のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
sourcebot-dev/sourcebot#1633 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sourcebot-dev/sourcebot#1384 · コメント 4 件 ·
-
ask_sb bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
sourcebot-dev/sourcebot#1137 · コメント 4 件 ·
-
bug triage needed
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
sourcebot-dev/sourcebot#1661 · コメント 1 件 ·
-
Feature
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
sourcebot-dev/sourcebot#1659 · コメント 1 件 ·
sourcebot-dev/sourcebot の issue をすべて見る
似ている issue
-
blocklist removal
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
MetaMask/eth-phishing-detect#296544 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pastelsky/bundlephobia#1122 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100