Skip to content

Commit ea1c5cc

Browse files
authored
fix(bench): resolve query benchmark CI failure and increase embedding timeout (#749)
* fix(bench): resolve doubled file paths in query benchmark on CI The query benchmark's benchDiffImpact reads row.file from the DB and joins it with the repo root, but on CI the npm-installed buildGraph stores paths that include the root directory prefix without a leading slash. This produces doubled paths like /root/root/src/... causing ENOENT. Add resolveDbFile() helper that detects absolute-like paths and falls back to prepending '/' when the joined path doesn't exist. Also increase embedding benchmark per-model timeout from 10→20 minutes and add explicit workflow timeout (180 min) so model downloads on cold CI caches don't cause silent failures. * fix(bench): return null from resolveDbFile and increase job timeout (#749) - resolveDbFile now returns null when no candidate exists, eliminating redundant existsSync calls in the caller - Bump embedding-benchmark job timeout from 180 to 195 min to provide adequate headroom for 7 cold-cache model downloads at 20 min each
1 parent a331b4e commit ea1c5cc

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ jobs:
156156
157157
embedding-benchmark:
158158
runs-on: ubuntu-latest
159+
# 7 models x 20 min each = 140 min worst-case + ~30 min setup/npm-wait headroom
160+
timeout-minutes: 195
159161
if: >-
160162
github.event_name == 'workflow_dispatch' ||
161163
(github.event.workflow_run.conclusion == 'success' &&
@@ -240,6 +242,7 @@ jobs:
240242

241243
- name: Run embedding benchmark
242244
if: steps.existing.outputs.skip != 'true'
245+
timeout-minutes: 160
243246
env:
244247
HF_TOKEN: ${{ secrets.HF_TOKEN }}
245248
run: |

scripts/embedding-benchmark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const dbPath = path.join(root, '.codegraph', 'graph.db');
125125

126126
const { MODELS } = await import(srcImport(srcDir, 'domain/search/index.js'));
127127

128-
const TIMEOUT_MS = 600_000;
128+
const TIMEOUT_MS = 1_200_000; // 20 min — model download + embedding can be slow on CI
129129
const hasHfToken = !!process.env.HF_TOKEN;
130130
const modelKeys = Object.keys(MODELS);
131131
const results = {};

scripts/query-benchmark.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ function benchDepths(fn, name, depths) {
176176
return result;
177177
}
178178

179+
/**
180+
* Resolve a file path from the DB to an absolute path.
181+
* Handles relative paths (normal) and absolute-like paths without leading '/'
182+
* (observed on CI when the npm-installed buildGraph stores full paths).
183+
*/
184+
function resolveDbFile(rootDir: string, dbFile: string): string | null {
185+
if (path.isAbsolute(dbFile)) return fs.existsSync(dbFile) ? dbFile : null;
186+
const joined = path.join(rootDir, dbFile);
187+
if (fs.existsSync(joined)) return joined;
188+
// DB may store an absolute path without the leading '/'
189+
const withSlash = '/' + dbFile;
190+
if (fs.existsSync(withSlash)) return withSlash;
191+
return null;
192+
}
193+
179194
function benchDiffImpact(hubName) {
180195
const db = new Database(dbPath, { readonly: true });
181196
const row = db
@@ -185,7 +200,14 @@ function benchDiffImpact(hubName) {
185200

186201
if (!row) return { latencyMs: 0, affectedFunctions: 0, affectedFiles: 0 };
187202

188-
const hubFile = path.join(root, row.file);
203+
// row.file is normally relative (e.g. 'src/domain/builder.ts'), but some
204+
// environments store absolute-like paths without the leading '/'. Handle
205+
// both cases so the benchmark works regardless of DB path format.
206+
const hubFile = resolveDbFile(root, row.file);
207+
if (!hubFile) {
208+
console.error(`[benchDiffImpact] Cannot find hub file for row.file=${row.file}`);
209+
return { latencyMs: 0, affectedFunctions: 0, affectedFiles: 0 };
210+
}
189211
const original = fs.readFileSync(hubFile, 'utf8');
190212

191213
try {

0 commit comments

Comments
 (0)