Problem/Motivation

build() loads the comment index for the thread, and the history lazy builder (CommentHistory::lazyBuilder) loads it again because the index is not passed through the lazy-builder arguments. Because the history builder is max-age 0 with user/user.permissions contexts, it runs on every node view, producing a second full 216-comment query plus access-check pass. The versions map also serializes and hashes every comment's toArray() on each of these runs.

Steps to reproduce

  • Open a node with 200+ comments under ACT.
  • Observe the comment index query and access checks run twice per page render.

Proposed resolution

  • Thread the built index (or its ids + metadata) into the history lazy builder so it is not rebuilt.
  • Alternatively, cache the index within the request so build() and lazyBuilder share it.

Remaining tasks

  • Confirm the index is built once per node render.

User interface changes

None, beyond faster node render.

API changes

Change the lazy-builder argument list to accept the index or its precomputed data.

Data model changes

None anticipated.

Comments

freelock created an issue. See original summary.

  • freelock committed 7346ee97 on 1.0.x
    fix: #3622843 Comment index built twice per node render
    

  • freelock committed 5b9f673c on 1.0.x
    fix: #3622843 Key the index memo per account and reset on comment...

  • freelock committed e1db11b1 on 1.0.x
    fix: #3622843 Tolerate stubbed accounts in the index memo key
    
freelock’s picture

Status: Active » Fixed

Fixed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.