From: Takashi Menjo =0A= Date: Mon, 16 Mar 2020 11:14:03 +0900=0A= Subject: [PATCH v2 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 ff7d0b69bd..382256369d 100644=0A= --- a/src/backend/access/transam/xlog.c=0A= +++ b/src/backend/access/transam/xlog.c=0A= @@ -993,6 +993,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= @@ -1002,6 +1004,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.17.1=0A= =0A= ------=_NextPart_000_000D_01D5FE00.9F87CD30 Content-Type: application/octet-stream; name="v2-0005-Map-WAL-segments-with-MAP_POPULATE-if-non-DAX.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="v2-0005-Map-WAL-segments-with-MAP_POPULATE-if-non-DAX.patch"