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

Commit5817d86

Browse files
committed
Optimize CleanupTempFiles by having a boolean flag that keeps track of whether
there are FD_XACT_TEMPORARY files to clean up at transaction end.Per performance profiling results on AWeber's huge systems.Patch by me after an idea suggested by Simon Riggs.
1 parent9fe79c3 commit5817d86

File tree

1 file changed

+18
-3
lines changed
  • src/backend/storage/file

1 file changed

+18
-3
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.144 2008/03/10 20:06:27 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.145 2008/09/19 04:57:10 alvherre Exp $
1111
*
1212
* NOTES:
1313
*
@@ -121,6 +121,12 @@ static intmax_safe_fds = 32;/* default if not changed */
121121
#defineFD_TEMPORARY(1 << 0)/* T = delete when closed */
122122
#defineFD_XACT_TEMPORARY(1 << 1)/* T = delete at eoXact */
123123

124+
/*
125+
* Flag to tell whether it's worth scanning VfdCache looking for temp files to
126+
* close
127+
*/
128+
staticboolhave_xact_temporary_files= false;
129+
124130
typedefstructvfd
125131
{
126132
intfd;/* current FD, or VFD_CLOSED if none */
@@ -889,6 +895,9 @@ OpenTemporaryFile(bool interXact)
889895
{
890896
VfdCache[file].fdstate |=FD_XACT_TEMPORARY;
891897
VfdCache[file].create_subid=GetCurrentSubTransactionId();
898+
899+
/* ensure cleanup happens at eoxact */
900+
have_xact_temporary_files= true;
892901
}
893902

894903
returnfile;
@@ -1608,7 +1617,7 @@ AtEOSubXact_Files(bool isCommit, SubTransactionId mySubid,
16081617
{
16091618
Indexi;
16101619

1611-
if (SizeVfdCache>0)
1620+
if (have_xact_temporary_files)
16121621
{
16131622
Assert(FileIsNotOpen(0));/* Make sure ring not corrupted */
16141623
for (i=1;i<SizeVfdCache;i++)
@@ -1684,7 +1693,11 @@ CleanupTempFiles(bool isProcExit)
16841693
{
16851694
Indexi;
16861695

1687-
if (SizeVfdCache>0)
1696+
/*
1697+
* Careful here: at proc_exit we need extra cleanup, not just
1698+
* xact_temporary files.
1699+
*/
1700+
if (isProcExit||have_xact_temporary_files)
16881701
{
16891702
Assert(FileIsNotOpen(0));/* Make sure ring not corrupted */
16901703
for (i=1;i<SizeVfdCache;i++)
@@ -1702,6 +1715,8 @@ CleanupTempFiles(bool isProcExit)
17021715
FileClose(i);
17031716
}
17041717
}
1718+
1719+
have_xact_temporary_files= false;
17051720
}
17061721

17071722
while (numAllocatedDescs>0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp