From: Takashi Menjo =0A= Date: Mon, 10 Feb 2020 17:53:15 +0900=0A= Subject: [msync 4/5] Speculative-map WAL segments=0A= =0A= ---=0A= src/backend/access/transam/xlog.c | 19 +++++++++++++++++++=0A= 1 file changed, 19 insertions(+)=0A= =0A= diff --git a/src/backend/access/transam/xlog.c = b/src/backend/access/transam/xlog.c=0A= index 317816a0b9..9b3caa63a4 100644=0A= --- a/src/backend/access/transam/xlog.c=0A= +++ b/src/backend/access/transam/xlog.c=0A= @@ -976,6 +976,8 @@ XLogInsertRecord(XLogRecData *rdata,=0A= info =3D=3D XLOG_SWITCH);=0A= XLogRecPtr StartPos;=0A= XLogRecPtr EndPos;=0A= + XLogRecPtr ProbablyInsertPos;=0A= + XLogSegNo ProbablyInsertSegNo;=0A= bool prevDoPageWrites =3D doPageWrites;=0A= =0A= /* we assume that all of the record header is in the first chunk */=0A= @@ -985,6 +987,23 @@ XLogInsertRecord(XLogRecData *rdata,=0A= if (!XLogInsertAllowed())=0A= elog(ERROR, "cannot make new WAL entries during recovery");=0A= =0A= + /* Speculatively map a segment we probably need */=0A= + ProbablyInsertPos =3D GetInsertRecPtr();=0A= + XLByteToSeg(ProbablyInsertPos, ProbablyInsertSegNo, wal_segment_size);=0A= + if (ProbablyInsertSegNo !=3D openLogSegNo)=0A= + {=0A= + if (mappedPages !=3D NULL)=0A= + {=0A= + Assert(beingUnmappedPages =3D=3D NULL);=0A= + Assert(beingClosedLogSegNo =3D=3D 0);=0A= + beingUnmappedPages =3D mappedPages;=0A= + beingClosedLogSegNo =3D openLogSegNo;=0A= + }=0A= + mappedPages =3D XLogFileMap(ProbablyInsertSegNo, &pmemMapped);=0A= + Assert(mappedPages !=3D NULL);=0A= + openLogSegNo =3D ProbablyInsertSegNo;=0A= + }=0A= +=0A= /*----------=0A= *=0A= * We have now done all the preparatory work we can without holding a=0A= -- =0A= 2.20.1=0A= =0A= ------=_NextPart_000_0001_01D5E040.09482730 Content-Type: application/octet-stream; name="0005-Allocate-WAL-segments-to-utilize-hugepage.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0005-Allocate-WAL-segments-to-utilize-hugepage.patch"