Playing with my undo-log storage, I found out that its performance is
mostly limited by generic WAL record mechanism,
and particularly by computeRegionDelta function which computes page
delta for each logged operation.
I noticed that computeRegionDelta also becomes bottleneck in other cases
where generic WAL records are used, for example in RUM extension.
This is profile of inserting records in table with RUM index:
I noticed that computeRegionDelta performs byte-by-byte comparison of page.
The obvious optimization is to compare words instead of bytes.
Small patch with such optimization is attached.
Definitely it may lead to small increase of produced deltas.
It is possible to calculate deltas more precisely: using work comparison
for raw location of region and then locate precise boundaries using bye
But it complicates algorithm and so makes it slower/
In practice, taken in account that header of record in Postgres is 24
bytes long and fields are usually aligned on 4/8 bytes boundary,
I think that calculating deltas in words is preferable.
Results of such optimization:
Performance of my UNDAM storage is increased from 6500 TPS to 7000 TPS
(vs. 8500 for unlogged table),
and computeRegionDelta completely disappears from RUM profile: