Problem/Motivation

CommentSliceRenderer::render() calls $builder->view() and then runs the view builder's build() pre-render callback eagerly for each rendered comment (src/CommentSliceRenderer.php:95-104). It does this to move the core links into the card's action row. Only after that does it set the per-comment #cache keys (:124-134). So a per-comment render-cache hit still pays for the display assembly. This is documented in docs/loading-strategies.md Known limitations ("Comment displays are built before the render-cache lookup").
How much this costs is not known. On a thread render-cache hit none of this code runs. It only matters on a thread miss, and on fragment routes (branch, context, comment, delivery, filter), which are never render-cached.

Proposed resolution

  1. Measure first. Compare warm and cold thread and fragment renders at 100/1,000 comments and full density: time spent in build() versus the rest. Stop here if the cost is negligible.
  2. If it matters, set the per-comment #cache keys before assembly and move the link relocation into a #pre_render callback (registered as a trusted callback) that runs only on a miss. Alternatively, check the render cache explicitly before calling build().

Remaining tasks

  • Add the measurements to this issue.
  • If implemented:
    • verify that links, edit/delete access and approval still bubble their per-user contexts;
    • verify that teaser bounding (boundContent()) still applies;
    • verify cache keys per density are unchanged.

User interface changes

None.

API changes

None.

Data model changes

None.

Related issues

None.

Comments

freelock created an issue.