model-writtenrun 2650 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- David Rowley proposed replacing the outdated 16-byte CHUNKHDRSZ estimate with sizeof(MemoryChunk), while avoiding backpatches because the correction could change spilling behavior #1.
- Tom Lane endorsed the correction and avoiding backpatches, then raised the larger overhead from power-of-two allocations and suggested considering a generation or Bump context #2.
- David explained that growing bucket arrays must support freeing allocations, while grouping tuples might benefit from Bump allocation; Tom clarified that hash_agg_entry_size predicts memory before actual tuples exist, and they agreed on separating tuple storage from bucket storage #3 #4 #5.
- David committed the CHUNKHDRSZ correction with a shortened comment, restricting it to the development branch to avoid plan instability in released versions d93bb8163c.
- John Naylor pointed to related work, and Jeff Davis clarified that bucket arrays already had a separate context, allowing grouping keys and per-group states to use Bump allocation if by-reference transition values remained separate #6 #7.
- Jeff posted a Bump-context proof of concept reporting roughly 15% less memory for a simple integer DISTINCT query, with similar or slightly better performance #9.
- David's review identified chunk-header charges that should disappear with Bump allocation and reported generally faster benchmarks but unexpectedly higher batch counts #10.
- Jeff revised the patch to correct entry estimates, account for power-of-two transition allocations, and refine context creation; he explained that more available memory can permit more spill partitions, while reporting mixed runtimes that still needed analysis #11.
- David identified an upstream change that made the repalloc workaround obsolete, and Jeff subsequently moved the optimization to another thread about reducing HashAgg memory usage, leaving this thread without a final revised attachment #12 #13.
- Jeff later committed the optimization derived from #11, with alignment and allocation-sizing changes, an accompanying CreateWorkExprContext update, and removal of the obsolete execGrouping.c workaround cc721c459d.