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

Commit7c979c9

Browse files
committed
Allocate all page images at once in generic wal interface
That reduces number of allocation.Per gripe from Michael Paquier and Tom Lane suggestion.
1 parentb09cd2e commit7c979c9

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,14 @@ typedef struct
6161
/* State of generic xlog record construction */
6262
structGenericXLogState
6363
{
64-
boolisLogged;
64+
/*
65+
* page's images. Should be first in this struct to have MAXALIGN'ed
66+
* images addresses, because some code working with pages directly aligns
67+
* addresses, not an offsets from begining of page
68+
*/
69+
charimages[MAX_GENERIC_XLOG_PAGES*BLCKSZ];
6570
PageDatapages[MAX_GENERIC_XLOG_PAGES];
71+
boolisLogged;
6672
};
6773

6874
staticvoidwriteFragment(PageData*pageData,OffsetNumberoffset,
@@ -267,16 +273,11 @@ GenericXLogStart(Relation relation)
267273
inti;
268274

269275
state= (GenericXLogState*)palloc(sizeof(GenericXLogState));
270-
271276
state->isLogged=RelationNeedsWAL(relation);
277+
272278
for (i=0;i<MAX_GENERIC_XLOG_PAGES;i++)
273279
{
274-
/*
275-
* pre-alloc page's images to prevent allocation in
276-
* GenericXLogRegisterBuffer() which could be called in different
277-
* memory context(s)
278-
*/
279-
state->pages[i].image=palloc(BLCKSZ);
280+
state->pages[i].image=state->images+BLCKSZ*i;
280281
state->pages[i].buffer=InvalidBuffer;
281282
}
282283

@@ -432,8 +433,6 @@ GenericXLogFinish(GenericXLogState *state)
432433
lsn=InvalidXLogRecPtr;
433434
}
434435

435-
for (i=0;i<MAX_GENERIC_XLOG_PAGES;i++)
436-
pfree(state->pages[i].image);
437436
pfree(state);
438437

439438
returnlsn;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp