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.
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:
generate_file_htmltotalextract_functionshtml_escape_fileget_all_line_testsget_cached_statsThere are no forks left in that loop — it is ~10
echos of markup per sourceline, 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_htmlitself:$(pwd),$(get_cached_stats …)and$(path_to_filename …)— 3 forks × 129pages.
Verification
Byte-identical HTML against a fixed corpus, as in #1096, plus the existing
fork census.