LabKit MATLAB Workbench

history

Documentation rendering avoids repeated model capture

id: LK-20260717-documentation-render-performance
date: 2026-07-17
sequence: 130
type: perf
compatibility: compatible
scope: MATLAB documentation renderer

Context

Two project documentation tests each rebuild the complete tracked site. Profiling showed that most render time was not file generation or tree comparison: every inline Markdown fragment created an anonymous function that captured the complete documentation model before scanning links.

Decision and rationale

Pass the shared model and current page directly into token protection and dispatch code, image, and link rendering by token type. This preserves the renderer contract and generated bytes while avoiding thousands of large closure allocations.

Changes

User and data impact

Generated HTML is byte-for-byte unchanged. Documentation rebuilds, consistency checks, and the launcher documentation action complete substantially sooner.

Compatibility and migration

renderLabKitDocs, checkLabKitDocs, buildtool docs, and buildtool docsCheck retain their existing syntax, outputs, and failure behavior. No migration is required.

Validation

On the same MATLAB R2025a host and complete checkLabKitDocs scenario, profiler total time decreased from 46.52 seconds to 9.66 seconds, approximately 79 percent. The after-profile run also completed the byte comparison against the tracked site.

Evidence

The focused renderer regression protects inline link behavior and the allocation fix. docsCheck independently rebuilds all narrative and API pages and compares every generated file.

Known limitations and follow-up

Absolute times vary by machine and filesystem. API help rendering is now the largest measured renderer-owned cost and should be changed only after a separate profile identifies a safe optimization.