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

Commit369aace

Browse files
committed
Avoid XLogFlush for clean buffers in BufferSync.
1 parent387d431 commit369aace

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.98 2000/11/30 19:03:25 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.99 2000/12/22 20:04:43 vadim Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -723,6 +723,7 @@ BufferSync()
723723
RelFileNodernode;
724724
XLogRecPtrrecptr;
725725
Relationreln=NULL;
726+
booldirty= false;
726727

727728
for (i=0,bufHdr=BufferDescriptors;i<NBuffers;i++,bufHdr++)
728729
{
@@ -745,6 +746,7 @@ BufferSync()
745746

746747
buffer=BufferDescriptorGetBuffer(bufHdr);
747748
rnode=bufHdr->tag.rnode;
749+
dirty=bufHdr->flags&BM_DIRTY;
748750

749751
SpinRelease(BufMgrLock);
750752

@@ -758,6 +760,17 @@ BufferSync()
758760
*/
759761
LockBuffer(buffer,BUFFER_LOCK_SHARE);
760762

763+
if (!dirty&& !(bufHdr->cntxDirty))
764+
{
765+
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
766+
SpinAcquire(BufMgrLock);
767+
UnpinBuffer(bufHdr);
768+
SpinRelease(BufMgrLock);
769+
if (reln!= (Relation)NULL)
770+
RelationDecrementReferenceCount(reln);
771+
continue;
772+
}
773+
761774
/*
762775
* Force XLOG flush for buffer' LSN
763776
*/
@@ -766,9 +779,8 @@ BufferSync()
766779

767780
/*
768781
* Now it's safe to write buffer to disk
769-
* (ifneeded at all -:))
782+
* (ifno one else already)
770783
*/
771-
772784
SpinAcquire(BufMgrLock);
773785
if (bufHdr->flags&BM_IO_IN_PROGRESS)
774786
WaitIO(bufHdr,BufMgrLock);
@@ -824,20 +836,19 @@ BufferSync()
824836
*/
825837
if (!(bufHdr->flags&BM_JUST_DIRTIED))
826838
bufHdr->flags &= ~BM_DIRTY;
839+
UnpinBuffer(bufHdr);
840+
SpinRelease(BufMgrLock);
827841
}
828842
else
843+
{
844+
UnpinBuffer(bufHdr);
845+
SpinRelease(BufMgrLock);
829846
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
830-
831-
UnpinBuffer(bufHdr);
832-
833-
SpinRelease(BufMgrLock);
847+
}
834848

835849
/* drop refcnt obtained by RelationNodeCacheGetRelation */
836850
if (reln!= (Relation)NULL)
837-
{
838851
RelationDecrementReferenceCount(reln);
839-
reln=NULL;
840-
}
841852
}
842853

843854
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp