Skip to content

🤖 perf: log caller location from raw call sites, not source-mapped stacks - #7126

Open
ThomasK33 wants to merge 2 commits into
mainfrom
perf/log-raw-callsites
Open

ThomasK33 wants to merge 2 commits into
mainfrom
perf/log-raw-callsites

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

The logger reads its caller location from raw V8 call sites, so a log line no longer runs source-map-support's stack hook. Refs #6556.

Before this change, every printed or persisted log line ran new Error().stack. src/desktop/main.ts and src/cli/server.ts install source-map-support/register, which maps each frame of each formatted stack, so the first log line from a file parsed that file's whole .js.map on the main thread. This hits both Electron main and xum server.

Implementation

  • getCallerLocation() swaps Error.prepareStackTrace for one capture (Error.captureStackTrace into a holder, read inside the override, previous hook restored in finally). It then scans the call sites with the same logger-frame skipping and the same formatCallerLocation output.
  • The logger-file check now matches /node/services/log.{ts,js}. Raw call sites name the compiled dist/node/services/log.js, which the old check only saw after source mapping.
  • Logged Error objects and uncaught exceptions keep source-mapped stacks. Only the location prefix of a log line changes.

Trade-off: dist builds, including make dev, show the compiled .js file and line (dist/node/services/workspaceService.js:3484) instead of the .ts line. The .js.map still ships next to each file, so the line can be mapped later. Bun (tests, bun runs of src) is unchanged, because there the sources are the .ts files.

Validation

  • log.test.ts › "a log line names its caller without running the global stack formatter": a counting global Error.prepareStackTrace stands in for source-map-support. log.info must call it 0 times, and the location must be src/node/services/log.test.ts:<line>. With origin/main's log.ts restored, it fails with Expected: 0, Received: 1. It passes under Bun 1.4.3, so Bun supports the CallSite API this needs.
  • Dist dogfood: node dist/cli/index.js server with a temp XUM_ROOT writes locations such as dist/node/services/serviceContainer.js:269 and dist/node/services/workspaceService.js:3484, and no line names log.js.
  • Server startup CPU profile, node --cpu-prof dist/cli/index.js server --port 0, 12 s, temp XUM_ROOT, 2 runs per side. The host is shared: 28 CPUs, load average 70-88 during the runs.
Side Total under getCallerLocation Total under SourceMapConsumer_parseMappings
origin/main fdfeb84d7b 365 ms, 269 ms 328 ms, 232 ms
this PR not sampled, 1.1 ms 1.2 ms, 1.1 ms

Desktop Cold Start (D2), base = main fdfeb84d7b, head = fe8a506b4b, 20 pairs x 3 repeats: run 39635019962.

Median xum:app-shell-ready mark (60 launches)
base 212.9 ms
head 159.6 ms

Paired statistic (20% trimmed mean of per-pair deltas): -24.9%, one-sided 95% upper bound -22.6%, half-width 2.33% (within the 2.5% gate).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $14.73

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T16:58:52.371299Z 99b211c Manual request
🔒 Security Review 🔄 Running since 2026-10-21T16:56:49.885318Z 99b211c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: fe8a506b4b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: fe8a506b4b

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 99b211c186

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
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