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

Commit2f7dd69

Browse files
author
Sokolov Yura
committed
remove inplace second pass gc
1 parentc43dbbc commit2f7dd69

File tree

1 file changed

+8
-45
lines changed
  • src/backend/storage/file

1 file changed

+8
-45
lines changed

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

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -768,15 +768,6 @@ typedef enum {
768768
CFS_IMPLICIT
769769
}GC_CALL_KIND;
770770

771-
/* spend 1% for more inplace updates on second pass */
772-
staticinlineuint32
773-
cfs_room_gc_chunk(uint32size)
774-
{
775-
if (size<CFS_MIN_COMPRESSED_SIZE(BLCKSZ))
776-
size+=size/128;
777-
returnsize;
778-
}
779-
780771
/*
781772
* Perform garbage collection (if required) on the file
782773
* @param map_path - path to the map file (*.cfm).
@@ -882,8 +873,6 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
882873
uint32second_pass=0;
883874
inode_t**inodes= (inode_t**)palloc(RELSEG_SIZE*sizeof(inode_t*));
884875
boolremove_backups= true;
885-
uint32inplace=0;
886-
boolprev_seek= false;
887876
intn_pages;
888877
TimestampTzstartTime,secondTime,endTime;
889878
longsecs,secs2;
@@ -955,10 +944,8 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
955944
cfs_state->gc_stat.processedFiles+=1;
956945
cfs_gc_processed_segments+=1;
957946

958-
newUsed=0;
959947
for (i=0;i<n_pages;i++)
960948
{
961-
introom;
962949
size=CFS_INODE_SIZE(*inodes[i]);
963950
if (size!=0)
964951
{
@@ -974,8 +961,7 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
974961
gotoCleanup;
975962
}
976963

977-
room=cfs_room_gc_chunk(size);
978-
if (!cfs_write_file(fd2,block,room))
964+
if (!cfs_write_file(fd2,block,size))
979965
{
980966
elog(WARNING,"CFS failed to write file %s: %m",file_bck_path);
981967
gotoCleanup;
@@ -984,8 +970,7 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
984970
cfs_state->gc_stat.processedPages+=1;
985971

986972
offs=newSize;
987-
newUsed+=size;
988-
newSize+=room;
973+
newSize+=size;
989974
*inodes[i]=CFS_INODE(size,offs);
990975

991976
/* xfs doesn't like if writeback performed closer than 128k to
@@ -1002,6 +987,7 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
1002987
*inodes[i]=CFS_INODE(0,0);
1003988
}
1004989
}
990+
newUsed=newSize;
1005991

1006992
/* Persist bigger part of copy to not do it under lock */
1007993
/* and persist previous file, cause it will be fsynced in durable rename */
@@ -1041,12 +1027,11 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10411027
map->inodes[i] &= ~CFS_INODE_CLEAN_FLAG;
10421028
continue;
10431029
}
1044-
second_pass++;
10451030
newUsed-=CFS_INODE_SIZE(nnode);
10461031
newUsed+=size;
10471032
if (size!=0)
10481033
{
1049-
introom;
1034+
second_pass++;
10501035
offs=CFS_INODE_OFFS(onode);
10511036

10521037
rc=lseek(fd,offs,SEEK_SET);
@@ -1060,29 +1045,8 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10601045
}
10611046

10621047
/* copy it without sorting */
1063-
room=cfs_room_gc_chunk(CFS_INODE_SIZE(nnode));
1064-
if (size <=room)
1065-
{
1066-
/* certainly need for uncompressable blocks.
1067-
* could be useful for other too */
1068-
prev_seek= true;
1069-
offs=CFS_INODE_OFFS(nnode);
1070-
rc=lseek(fd2,offs,SEEK_SET);
1071-
Assert(rc== (off_t)offs);
1072-
inplace++;
1073-
}
1074-
else
1075-
{
1076-
if (prev_seek)
1077-
{
1078-
prev_seek= false;
1079-
rc=lseek(fd2,0,SEEK_END);
1080-
Assert(rc>0);
1081-
Assert(rc==newSize);
1082-
}
1083-
offs=newSize;
1084-
newSize+=size;
1085-
}
1048+
offs=newSize;
1049+
newSize+=size;
10861050
if (!cfs_write_file(fd2,block,size))
10871051
{
10881052
elog(WARNING,"CFS failed to write file %s: %m",file_bck_path);
@@ -1092,7 +1056,6 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
10921056
}
10931057
else
10941058
{
1095-
newUsed-=CFS_INODE_SIZE(newMap->inodes[i]);
10961059
newMap->inodes[i]=CFS_INODE(0,0);
10971060
}
10981061
cfs_state->gc_stat.processedBytes+=size;
@@ -1268,10 +1231,10 @@ static bool cfs_gc_file(char* map_path, GC_CALL_KIND background)
12681231

12691232
if (succeed)
12701233
{
1271-
elog(LOG,"CFS GC worker %d: defragment file %s: old size %u, new size %u, logical size %u, used %u, compression ratio %f, time %ld usec; second pass: pages %u,inplace %u,time %ld"
1234+
elog(LOG,"CFS GC worker %d: defragment file %s: old size %u, new size %u, logical size %u, used %u, compression ratio %f, time %ld usec; second pass: pages %u, time %ld"
12721235
,
12731236
MyProcPid,file_path,physSize,newSize,virtSize,usedSize, (double)virtSize/newSize,
1274-
secs*USECS_PER_SEC+usecs,second_pass,inplace,
1237+
secs*USECS_PER_SEC+usecs,second_pass,
12751238
secs2*USECS_PER_SEC+usecs2);
12761239
}
12771240

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp