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

Commit923e994

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
ARC strategy backed out ... sorry
Jan
1 parent256d2f0 commit923e994

File tree

9 files changed

+216
-932
lines changed

9 files changed

+216
-932
lines changed

‎src/backend/commands/vacuum.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.266 2003/11/1300:40:00 wieck Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.267 2003/11/1305:34:57 wieck Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -33,7 +33,6 @@
3333
#include"commands/vacuum.h"
3434
#include"executor/executor.h"
3535
#include"miscadmin.h"
36-
#include"storage/buf_internals.h"
3736
#include"storage/freespace.h"
3837
#include"storage/sinval.h"
3938
#include"storage/smgr.h"
@@ -311,16 +310,8 @@ vacuum(VacuumStmt *vacstmt)
311310
else
312311
old_context=MemoryContextSwitchTo(anl_context);
313312

314-
/*
315-
* Tell the buffer replacement strategy that vacuum is
316-
* causing the IO
317-
*/
318-
StrategyHintVacuum(true);
319-
320313
analyze_rel(relid,vacstmt);
321314

322-
StrategyHintVacuum(false);
323-
324315
if (vacstmt->vacuum)
325316
CommitTransactionCommand();
326317
else
@@ -758,12 +749,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
758749
SetQuerySnapshot();/* might be needed for functions in
759750
* indexes */
760751

761-
/*
762-
* Tell the cache replacement strategy that vacuum is causing
763-
* all following IO
764-
*/
765-
StrategyHintVacuum(true);
766-
767752
/*
768753
* Check for user-requested abort.Note we want this to be inside a
769754
* transaction, so xact.c doesn't issue useless WARNING.
@@ -778,7 +763,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
778763
ObjectIdGetDatum(relid),
779764
0,0,0))
780765
{
781-
StrategyHintVacuum(false);
782766
CommitTransactionCommand();
783767
return true;/* okay 'cause no data there */
784768
}
@@ -812,7 +796,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
812796
(errmsg("skipping \"%s\" --- only table or database owner can vacuum it",
813797
RelationGetRelationName(onerel))));
814798
relation_close(onerel,lmode);
815-
StrategyHintVacuum(false);
816799
CommitTransactionCommand();
817800
return false;
818801
}
@@ -827,7 +810,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
827810
(errmsg("skipping \"%s\" --- cannot vacuum indexes, views, or special system tables",
828811
RelationGetRelationName(onerel))));
829812
relation_close(onerel,lmode);
830-
StrategyHintVacuum(false);
831813
CommitTransactionCommand();
832814
return false;
833815
}
@@ -842,7 +824,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
842824
if (isOtherTempNamespace(RelationGetNamespace(onerel)))
843825
{
844826
relation_close(onerel,lmode);
845-
StrategyHintVacuum(false);
846827
CommitTransactionCommand();
847828
return true;/* assume no long-lived data in temp
848829
* tables */
@@ -882,7 +863,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
882863
/*
883864
* Complete the transaction and free all temporary memory used.
884865
*/
885-
StrategyHintVacuum(false);
886866
CommitTransactionCommand();
887867

888868
/*

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

Lines changed: 18 additions & 8 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/buf_init.c,v 1.55 2003/11/1300:40:01 wieck Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.56 2003/11/1305:34:58 wieck Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -48,6 +48,9 @@ long *CurTraceBuf;
4848
intShowPinTrace=0;
4949

5050
intData_Descriptors;
51+
intFree_List_Descriptor;
52+
intLookup_List_Descriptor;
53+
intNum_Descriptors;
5154

5255
BufferDesc*BufferDescriptors;
5356
Block*BufferBlockPointers;
@@ -130,6 +133,9 @@ InitBufferPool(void)
130133
inti;
131134

132135
Data_Descriptors=NBuffers;
136+
Free_List_Descriptor=Data_Descriptors;
137+
Lookup_List_Descriptor=Data_Descriptors+1;
138+
Num_Descriptors=Data_Descriptors+1;
133139

134140
/*
135141
* It's probably not really necessary to grab the lock --- if there's
@@ -150,7 +156,7 @@ InitBufferPool(void)
150156

151157
BufferDescriptors= (BufferDesc*)
152158
ShmemInitStruct("Buffer Descriptors",
153-
Data_Descriptors*sizeof(BufferDesc),&foundDescs);
159+
Num_Descriptors*sizeof(BufferDesc),&foundDescs);
154160

155161
BufferBlocks= (char*)
156162
ShmemInitStruct("Buffer Blocks",
@@ -170,14 +176,16 @@ InitBufferPool(void)
170176
block=BufferBlocks;
171177

172178
/*
173-
* link the buffers into a single linked list. This will become the
174-
* LiFo list of unused buffers returned by StragegyGetBuffer().
179+
* link the buffers into a circular, doubly-linked list to
180+
* initialize free list, and initialize the buffer headers. Still
181+
* don't know anything about replacement strategy in this file.
175182
*/
176183
for (i=0;i<Data_Descriptors;block+=BLCKSZ,buf++,i++)
177184
{
178185
Assert(ShmemIsValid((unsigned long)block));
179186

180-
buf->bufNext=i+1;
187+
buf->freeNext=i+1;
188+
buf->freePrev=i-1;
181189

182190
CLEAR_BUFFERTAG(&(buf->tag));
183191
buf->buf_id=i;
@@ -191,12 +199,14 @@ InitBufferPool(void)
191199
buf->wait_backend_id=0;
192200
}
193201

194-
/* Correct last entry */
195-
BufferDescriptors[Data_Descriptors-1].bufNext=-1;
202+
/* close the circular queue */
203+
BufferDescriptors[0].freePrev=Data_Descriptors-1;
204+
BufferDescriptors[Data_Descriptors-1].freeNext=0;
196205
}
197206

198207
/* Init other shared buffer-management stuff */
199-
StrategyInitialize(!foundDescs);
208+
InitBufTable();
209+
InitFreeList(!foundDescs);
200210

201211
LWLockRelease(BufMgrLock);
202212
}

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

Lines changed: 42 additions & 26 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/buf_table.c,v 1.30 2003/11/1300:40:01 wieck Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.31 2003/11/1305:34:58 wieck Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -38,7 +38,7 @@ static HTAB *SharedBufHash;
3838
* Initialize shmem hash table for mapping buffers
3939
*/
4040
void
41-
InitBufTable(intsize)
41+
InitBufTable(void)
4242
{
4343
HASHCTLinfo;
4444

@@ -50,71 +50,87 @@ InitBufTable(int size)
5050
info.hash=tag_hash;
5151

5252
SharedBufHash=ShmemInitHash("Shared Buffer Lookup Table",
53-
size,size,
53+
NBuffers,NBuffers,
5454
&info,
5555
HASH_ELEM |HASH_FUNCTION);
5656

5757
if (!SharedBufHash)
5858
elog(FATAL,"could not initialize shared buffer hash table");
5959
}
6060

61-
/*
62-
* BufTableLookup
63-
*/
64-
int
61+
BufferDesc*
6562
BufTableLookup(BufferTag*tagPtr)
6663
{
6764
BufferLookupEnt*result;
6865

6966
if (tagPtr->blockNum==P_NEW)
70-
return-1;
67+
returnNULL;
7168

7269
result= (BufferLookupEnt*)
7370
hash_search(SharedBufHash, (void*)tagPtr,HASH_FIND,NULL);
7471
if (!result)
75-
return-1;
72+
returnNULL;
7673

77-
returnresult->id;
74+
return&(BufferDescriptors[result->id]);
7875
}
7976

8077
/*
8178
* BufTableDelete
8279
*/
8380
bool
84-
BufTableInsert(BufferTag*tagPtr,Bufferbuf_id)
81+
BufTableDelete(BufferDesc*buf)
8582
{
8683
BufferLookupEnt*result;
87-
boolfound;
8884

89-
result= (BufferLookupEnt*)
90-
hash_search(SharedBufHash, (void*)tagPtr,HASH_ENTER,&found);
85+
/*
86+
* buffer not initialized or has been removed from table already.
87+
* BM_DELETED keeps us from removing buffer twice.
88+
*/
89+
if (buf->flags&BM_DELETED)
90+
return TRUE;
9191

92-
if (!result)
93-
ereport(ERROR,
94-
(errcode(ERRCODE_OUT_OF_MEMORY),
95-
errmsg("out of shared memory")));
92+
buf->flags |=BM_DELETED;
9693

97-
if (found)/* found something else in the table? */
94+
result= (BufferLookupEnt*)
95+
hash_search(SharedBufHash, (void*)&(buf->tag),HASH_REMOVE,NULL);
96+
97+
if (!result)/* shouldn't happen */
9898
elog(ERROR,"shared buffer hash table corrupted");
9999

100-
result->id=buf_id;
100+
/*
101+
* Clear the buffer's tag. This doesn't matter for the hash table,
102+
* since the buffer is already removed from it, but it ensures that
103+
* sequential searches through the buffer table won't think the buffer
104+
* is still valid for its old page.
105+
*/
106+
buf->tag.rnode.relNode=InvalidOid;
107+
buf->tag.rnode.tblNode=InvalidOid;
108+
101109
return TRUE;
102110
}
103111

104-
/*
105-
* BufTableDelete
106-
*/
107112
bool
108-
BufTableDelete(BufferTag*tagPtr)
113+
BufTableInsert(BufferDesc*buf)
109114
{
110115
BufferLookupEnt*result;
116+
boolfound;
117+
118+
/* cannot insert it twice */
119+
Assert(buf->flags&BM_DELETED);
120+
buf->flags &= ~(BM_DELETED);
111121

112122
result= (BufferLookupEnt*)
113-
hash_search(SharedBufHash, (void*)tagPtr,HASH_REMOVE,NULL);
123+
hash_search(SharedBufHash, (void*)&(buf->tag),HASH_ENTER,&found);
114124

115-
if (!result)/* shouldn't happen */
125+
if (!result)
126+
ereport(ERROR,
127+
(errcode(ERRCODE_OUT_OF_MEMORY),
128+
errmsg("out of shared memory")));
129+
130+
if (found)/* found something else in the table? */
116131
elog(ERROR,"shared buffer hash table corrupted");
117132

133+
result->id=buf->buf_id;
118134
return TRUE;
119135
}
120136

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp