model-writtenrun 5985 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Nathan Bossart reported standby startup stalls caused by repeatedly deleting the first element of an array-backed List and proposed foreach() traversal followed by bulk freeing; his synthetic benchmark reduced processing 500,000 integers from about a minute to six milliseconds #1.
- Amul Sul and Kyotaro Horiguchi endorsed the fix, Kyotaro identified similar loops elsewhere, and Michael Paquier reproduced the performance difference and recommended backpatching to PostgreSQL 13 #2 #3 #4.
- Andres Freund raised error-recovery concerns and suggested deleting from the tail, but Nathan and Tom Lane preferred preserving lock-release order; Nathan explained that an error interrupting this startup-process loop would restart the process rather than reuse a partially released list #6 #7 #10 #11 #14.
- Tom confirmed that the lock list need not survive an error consistently and committed Nathan's original patch unchanged as 6301c3adab, with backpatches through PostgreSQL 13 #15.
- Tom's wider audit produced a separate pg_trgm patch and identified checkpoint cleanup, hash aggregation, and LLVM cleanup as further candidates, while questioning whether GiST, COPY, parser, and namespace lists were large enough to justify more complex changes #17.
- Kyotaro and Nathan questioned pg_trgm queue cleanup, and Tom explained why processState() should free its repeatedly allocated queue while transformGraph() could rely on its surrounding memory context; Nathan accepted that reasoning #18 #19 #21 #22 #23.
- Tom expanded the unchanged pg_trgm patch with foreach() cleanup for LLVM and end-of-list stack operations for hash aggregation; Nathan approved the expanded patch, which landed unchanged as e9d9ba2a4d and was backpatched through PostgreSQL 13 #24 #25.
- Kyotaro and Nathan suggested bulk deletion for checkpoint processing, and Tom implemented list_delete_first_n() together with a canceled flag so SyncPostCheckpoint() could preserve valid state during AbsorbSyncRequests() and compact the list only once per call #18 #21 #26.
- Kyotaro requested skipping canceled entries before checking the checkpoint cycle, and Tom accepted that improvement; 65c6cab136 landed from the checkpoint patch with that adjustment and two additional conversions from list_copy_tail() to list_delete_first_n(), with backpatches through PostgreSQL 13 #29 #30 #31.
- After the checkpoint fix, Tom stopped the functional audit because the remaining callers had no demonstrated performance problem and changing them would be complex, leaving further work contingent on evidence of an actual issue #31.
- Andres then proposed documenting list_delete_first() complexity, Tom broadened the proposal to other List functions, and Michael suggested also documenting the header; Tom chose to keep API descriptions beside their implementations in list.c #33 #34 #35 #36.
- Tom posted the performance-documentation patch, and Andres suggested pointing readers toward list_delete_last(); Tom revised the advice to explain when reversing list operations helps, and Andres approved it #37 #38 #39 #40.
- The documentation landed with those light comment edits as 27ef132a80, and Tom's final confirmation closed the thread with all submitted patches incorporated and the remaining speculative caller optimizations deferred #41.