Skip to content

perf(repl): count a diagnostic's UTF-16 column without encoding the line - #1352

Merged
HuiJun merged 1 commit into
developfrom
perf/utf16-column-without-encoding
Oct 21, 2026
Merged

HuiJun merged 1 commit into
developfrom
perf/utf16-column-without-encoding

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Since #1205 (SARIF/CI formats count columns in UTF-16) every sysml diagnostic carries a UTF16Column, computed by utf16Column as len(utf16.Encode([]rune(string(content[lineStart:offset])))): an encoded copy of the line prefix per diagnostic (and two more per quick fix), thrown away after its length is read. The snippet path also converted the whole snippet source to []byte twice per diagnostic (utf16Column([]byte(sn.src), …), locatedFixes(…, []byte(sn.src), …)). In the 0.11.0 release-gate measurement internal/frontend/repl BenchmarkDiagnostics reads 755 → 1 044 B/diagnostic (attributes=50), 638 → 929 (200), 574 → 829 (800) against 0.10.1; the allocation profile puts the utf16.Encode copies at about half of the new allocations per diagnostic (the rest, and nearly all of the new bytes, is the semantics work of #1276/#1319 — AllSupertypes and the wider type sets — measured separately).

The column is now counted in place: utf16Units walks the prefix with utf8.DecodeRune, two units for an astral rune, one otherwise — the same count utf16.Encode gives, including one unit for an invalid byte (RuneError). The snippet source is converted to bytes once per snippet, beside the line index it already caches per snippet. Columns are unchanged.

How it was verified

Checklist

  • make test and make lint pass locally (repl package run locally; the full suite runs in CI)
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (no doc covers this internal)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (no gate count moved)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/cf22d7a746814d20b2f0eaf11682fef9
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/cf22d7a746814d20b2f0eaf11682fef9?variant=devin
Requested by: @HuiJun

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review October 21, 2026 11:37
@HuiJun
HuiJun merged commit e5bdb8f into develop Oct 21, 2026
53 checks passed
@HuiJun
HuiJun deleted the perf/utf16-column-without-encoding branch October 21, 2026 14:01
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