You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "liuxiaocs7 (via GitHub)" <gi...@apache.org> on 2026/09/12 18:58:50 UTC
[I] perf(core): count diff lines without materializing display rows [maka]
liuxiaocs7 opened a new issue, #5242:
URL: https://github.com/apache/maka/issues/5242
### Problem
`countDiffLineStats` currently calls `parseUnifiedDiffRows`, which splits the complete diff into a line array, creates display objects for every row (including context and metadata), and then walks those objects just to return two numbers.
This work is paid by Git review snapshots, tool activity badges, CLI summaries, and model-facing file-tool summaries. The temporary allocations grow with the full diff even when the caller never displays its rows.
At commit `d2e1be5db93101ffcc0fb6a107a0d51764ace28b`, a synthetic 100,000-line replacement diff (~4.77 MiB) creates 100,001 display objects. On Apple M4 Pro / Node v24.14.0, its count-only call takes a median 2.754 ms and increases `heapUsed` by about 11.02 MiB. The heap number is a before/after delta, not an exact peak or total allocation measurement.
Source: [`packages/core/src/unified-diff.ts`](https://github.com/apache/maka/blob/d2e1be5db93101ffcc0fb6a107a0d51764ace28b/packages/core/src/unified-diff.ts#L124).
### Desired outcome
- Count additions and deletions without constructing display rows or a complete line array.
- Keep counting and display parsing on the same hunk state machine, preserving existing results and display-row shapes.
- Cover file headers versus header-like body content, multiple files/hunks, blank lines, CRLF, no-newline markers, zero-count and truncated hunks.
- Provide reproducible before/after timing and heap measurements, plus a display-parser regression check.
### Alternatives or workarounds
Callers currently use the complete display parser. Caching at each caller would retain data and duplicate policy across surfaces. Counting `+`/`-` prefixes alone would misclassify headers and body lines such as `--- comment` / `+++i`; a shared structural scanner preserves the existing semantics.
Automated submission by Codex on behalf of @liuxiaocs7, who requested this issue and the associated contribution. Codex assisted with diagnosis, implementation, tests, and benchmarking.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [I] perf(core): count diff lines without materializing display rows [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han closed issue #5242: perf(core): count diff lines without materializing display rows
URL: https://github.com/apache/maka/issues/5242
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [I] perf(core): count diff lines without materializing display rows [maka]
Posted by "liuxiaocs7 (via GitHub)" <gi...@apache.org>.
liuxiaocs7 commented on issue #5242:
URL: https://github.com/apache/maka/issues/5242#issuecomment-5648010525
take
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org