Skip to content

perf(coverage): emit each HTML page in one awk pass instead of a Bash loop per line #1098

Closed

Description

@Chemaclass

Problem

With the per-line escaping fixed (#1096) the HTML report is 9.5s for 128
files, and 8.1s of that is generate_file_html — 63 ms per page.

Where that goes, measured on Bash 3.2 arm64 over 128 files / 22,405 source
lines:

128 pages
generate_file_html total 8116 ms
of which extract_functions 450 ms
of which html_escape_file 331 ms
of which get_all_line_tests 301 ms
of which get_cached_stats 28 ms
the Bash markup loop itself ~7000 ms

There are no forks left in that loop — it is ~10 echos of markup per source
line, 22,405 times, plus the string building for the hit badge and tooltip.
Bash is simply the wrong tool for emitting 7 MB of HTML.

Proposal

Emit the page body in one awk pass, the shape that took the LCOV report from
3133 ms to 267 ms (#1090). awk already receives everything the loop needs: the
source lines, the propagated hit counts, the executable classification and the
per-line test list.

Also worth taking while there, all per page in report_html itself:
$(pwd), $(get_cached_stats …) and $(path_to_filename …) — 3 forks × 129
pages.

Verification

Byte-identical HTML against a fixed corpus, as in #1096, plus the existing
fork census.

Activity

  1. self-assigned this
    on Aug 13, 2026
  2. Chemaclass commented on Aug 13, 2026

    @Chemaclass
    MemberAuthor

    Done in #1100 (merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions