> Not sure but it might be possible to keep holding an xlogreader for > reading PREPARE WAL records even after the transaction commit. But I > wonder how much open() for wal segment file accounts for the total > execution time of 2PC. 2PC requires 2 network round trips for each > participant. For example, if it took 500ms in total, we would not get > benefits much from the point of view of 2PC performance even if we > improved it from 14ms to 1ms.
I made the patch based on your advice and re-run the test on the new machine. (The attached patch is just for test purpose.)
Wouldn't it be better to explicitly initialize the pointer with NULL? I think it's common in Postgres.
static XLogReaderState *xlogreader = NULL;
* foreign_twophase_commit = disabled 2686tps
* foreign_twophase_commit = required (It is necessary to set -R ${RATE} as Ikeda-san said) 311tps
* foreign_twophase_commit = required with attached patch (It is not necessary to set -R ${RATE}) 2057tps