Hi, Thank you for running the benchmark and updating the patch. Please find my comments inline below.
> > All microbenchmark cases below use one resource kind. Columns are: > > Timing: Release = all three release phases; > Reset = Reset alone after release has completed. > Live/peak: resource count before release / peak registered count. > For Reset, the peak is established before timing. > Baseline: unpatched. > A: clear hash entries during sorting and bulk release. > B: clear the retained hash table in Reset. I think the most interesting cases are when the live count or the number of resources held at a given time exceed 32. That is when the hash table, and so the v4 patch's code, gets used. > > | Timing | Live/peak | Baseline | A | B | > +----------+-------------+-----------+-----------+-----------+ > | Release | 0/0 | 0.026 | 0.029 | 0.027 | > | Release | 16/16 | 0.108 | 0.116 | 0.107 | > | Release | 32/32 | 0.202 | 0.207 | 0.198 | > | Release | 33/33 | 0.282 | 0.277 | 0.268 | > | Release | 64/64 | 0.463 | 0.466 | 0.456 | > | Release | 128/128 | 0.954 | 0.977 | 0.939 | > | Release | 1024/1024 | 11.617 | 11.341 | 11.825 | > | Release | 16384/16384 | 239.506 | 256.352 | 237.873 | > | Release | 0/1024 | 0.040 | 0.044 | 0.038 | > | Release | 16/1024 | 2.051 | 1.790 | 1.854 | > > For Release, the smaller cases tested show small absolute differences. > The difference is more apparent with 16,384 resources. > Clearing entries on release costs about 7% more at ~16k live resources. That case could be rare: in a scale-100 pgbench run, no owner held more than 150 resources at once, so I don't expect a noticeable TPS regression. > To check whether A's extra release work affects SQL throughput, > I also ran pgbench -S -M prepared -c 1 -j 1 at scale 1. TPS values > below are medians; differences compare those medians with baseline. > > +----------+------------+------------+--------+ > | Run | Baseline | A | A diff | > +----------+------------+------------+--------+ > | First | 43736.94 | 43035.63 | -1.60% | > | Repeat | 43340.50 | 43574.31 | +0.54% | > +----------+------------+------------+--------+ > Nice. Additionally, to rule out any TPS regression it would be nice to repeat this with a higher scale and with a read-write workload. > > Given these results, I prefer clearing during sorting and bulk > release. It avoids clearing the full retained table in Reset, and > these pgbench runs did not show a consistent throughput regression. > Attached with v4. +1 for clearing while sorting and release. > * If 'sorted' is set, the contents are no longer hashed, but sorted by >- * release priority. The first 'nhash' elements are occupied, the rest >- * are empty. >+ * release priority. The first 'nhash' elements contain the remaining >+ * resources; entries after that are not used until the owner is reset or >+ * deleted. This change no longer holds with the recent patch. The older comment was more appropriate given the latest changes. >+ Assert(owner->nlocks == 0 || owner->nlocks == MAX_RESOWNER_LOCKS + 1); >+ Assert(dlist_is_empty(&owner->aio_handles)); >+ >+ for (child = owner->firstchild; child != NULL; child = child->nextchild) >+ ResourceOwnerReset(child); >+ >+ owner->nlocks = 0; A comment explaining why it is safe to set nlocks to 0 even when the old value is MAX_RESOWNER_LOCKS + 1 , would be useful. Do we also need to reset the owner->locks along with it? I suggest backpatching only the changes that clear the unused entries, through v17 and keeping the changes to add the new API ResourceOwnerReset() for master only. Thank you, Rahila Syed
