Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2b37d9

Browse files
committed
Use pg_pread() and pg_pwrite() in slru.c.
This avoids lseek() system calls at every SLRU I/O, as wasdone for relation files in commit c24dcd0c.Reviewed-by: Ashwin Agrawal <aagrawal@pivotal.io>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/CA%2BhUKG%2Biqke4uTRFj8D8uEUUgj%2BRokPSp%2BCWM6YYzaaamG9Wvg%40mail.gmail.comDiscussion:https://postgr.es/m/CA%2BhUKGJ%2BoHhnvqjn3%3DHro7xu-YDR8FPr0FL6LF35kHRX%3D_bUzg%40mail.gmail.com
1 parent022350b commite2b37d9

File tree

1 file changed

+4
-21
lines changed
  • src/backend/access/transam

1 file changed

+4
-21
lines changed

‎src/backend/access/transam/slru.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
669669
SlruSharedshared=ctl->shared;
670670
intsegno=pageno /SLRU_PAGES_PER_SEGMENT;
671671
intrpageno=pageno %SLRU_PAGES_PER_SEGMENT;
672-
intoffset=rpageno*BLCKSZ;
672+
off_toffset=rpageno*BLCKSZ;
673673
charpath[MAXPGPATH];
674674
intfd;
675675

@@ -699,17 +699,9 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
699699
return true;
700700
}
701701

702-
if (lseek(fd, (off_t)offset,SEEK_SET)<0)
703-
{
704-
slru_errcause=SLRU_SEEK_FAILED;
705-
slru_errno=errno;
706-
CloseTransientFile(fd);
707-
return false;
708-
}
709-
710702
errno=0;
711703
pgstat_report_wait_start(WAIT_EVENT_SLRU_READ);
712-
if (read(fd,shared->page_buffer[slotno],BLCKSZ)!=BLCKSZ)
704+
if (pg_pread(fd,shared->page_buffer[slotno],BLCKSZ,offset)!=BLCKSZ)
713705
{
714706
pgstat_report_wait_end();
715707
slru_errcause=SLRU_READ_FAILED;
@@ -749,7 +741,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
749741
SlruSharedshared=ctl->shared;
750742
intsegno=pageno /SLRU_PAGES_PER_SEGMENT;
751743
intrpageno=pageno %SLRU_PAGES_PER_SEGMENT;
752-
intoffset=rpageno*BLCKSZ;
744+
off_toffset=rpageno*BLCKSZ;
753745
charpath[MAXPGPATH];
754746
intfd=-1;
755747

@@ -862,18 +854,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
862854
}
863855
}
864856

865-
if (lseek(fd, (off_t)offset,SEEK_SET)<0)
866-
{
867-
slru_errcause=SLRU_SEEK_FAILED;
868-
slru_errno=errno;
869-
if (!fdata)
870-
CloseTransientFile(fd);
871-
return false;
872-
}
873-
874857
errno=0;
875858
pgstat_report_wait_start(WAIT_EVENT_SLRU_WRITE);
876-
if (write(fd,shared->page_buffer[slotno],BLCKSZ)!=BLCKSZ)
859+
if (pg_pwrite(fd,shared->page_buffer[slotno],BLCKSZ,offset)!=BLCKSZ)
877860
{
878861
pgstat_report_wait_end();
879862
/* if write didn't set errno, assume problem is no disk space */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp