Skip to content

fix(core): find the git root of ES module benchmarks from their file - #129

Merged
lvaroqui merged 1 commit into
mainfrom
fix/esm-calling-file-git-root
Nov 26, 2026
Merged

lvaroqui merged 1 commit into
mainfrom
fix/esm-calling-file-git-root

Conversation

@lvaroqui

Copy link
Copy Markdown
Contributor

Converts the file:// URL of an ES module benchmark to a path before looking up its git repository, so the URI is relative to the repository that contains the benchmark file.

getCallingFile passed the stack trace file name to getGitDir as is. For ES modules, that name is a file:// URL, which path.resolve treats as a relative path under the current directory. The lookup then found the repository of the current directory instead of the one of the benchmark file:

  • Run from another repository, the URI started with ../. A URL parser resolves these segments, so the benchmark page 404s and the flame graph can't be stored or downloaded.
  • Run from a directory outside any repository, it threw "Could not find a git repository".

CommonJS benchmarks and the Vitest plugin already looked up the repository from the benchmark file; ES modules now do the same.

URI change: ES module benchmarks get a new URI, so their history restarts, when the benchmark file is in another repository than the current directory. This includes a file in a submodule or nested repository, run from the outer repository: its URI is now relative to the inner repository. A changelog note for 7.0 should mention it.

getGitRelativePath is exported from @codspeed/core, as utils.ts is re-exported as a whole, so the tests can call it without a stack trace.

Refs COD-4223: the issue also covers fixes in other integrations and in the CodSpeed app, so it stays open.

@codspeed

codspeed Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 14.13%

5 warnings, 1 note

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 14 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark with a significant change ran in a different software environment

Its base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the change might come from this difference rather than from the code. Open the benchmark to see what changed.

See affected benchmarks

⚠️ 60 benchmarks are too noisy to detect regressions

Their results vary so much between runs that only very large changes would be flagged. Investigate what causes this variance to catch their regressions.

See affected benchmarks

ℹ️ 16 benchmarks have no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 268 untouched benchmarks
⏩ 56 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Walltime fibo darwin 5.3 ms 9 ms -40.98%
⚡ Memory wait 1sec 27.5 KB 22 KB +24.96%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/esm-calling-file-git-root (dc28e18) with main (0979664)

Open in CodSpeed

Footnotes

  1. 56 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@lvaroqui
lvaroqui marked this pull request as ready for review November 26, 2026 15:32
@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Converts ES module file URLs before finding the benchmark's Git root.

  • Benchmark URIs now use the repository that contains the benchmark file.

Reviews (1) · Last reviewed commit: "fix(core): find the git root of ES modul..." · Reviewed by Greptile

Comment thread packages/core/src/utils.ts Resolved
getCallingFile passed the stack trace file name to getGitDir as is. For ES modules,
that name is a file:// URL, which path.resolve treats as a relative path under the
current directory. The lookup then found the repository of the current directory
instead of the one of the benchmark file:
- run from another repository, the URI started with `../`, which breaks the
  benchmark page and the flame graph
- run from a directory outside any repository, it threw "Could not find a git
  repository"

The URL is now converted to a path before the lookup, so ES modules behave like
CommonJS and the Vitest plugin. URIs of ES module benchmarks change when the
benchmark file is in another repository than the current directory, including a
submodule or nested repository run from the outer one.

Refs COD-4223
Co-Authored-By: Claude <noreply@anthropic.com>
@lvaroqui
lvaroqui force-pushed the fix/esm-calling-file-git-root branch from 373bd5d to dc28e18 Compare November 26, 2026 16:41
@lvaroqui
lvaroqui merged commit 1369ec1 into main Nov 26, 2026
47 of 48 checks passed
@lvaroqui
lvaroqui deleted the fix/esm-calling-file-git-root branch November 26, 2026 17:18
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.

2 participants