pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Kapila <amit.kapila@huawei.com>
To: 'PostgreSQL-development' <pgsql-hackers@postgreSQL.org>
Subject: Move unused buffers to freelist
Date: Tue, 14 May 2013 19:12:27 +0530
Message-ID: <002f01ce50a8$e057c7a0$a10756e0$@kapila@huawei.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

As discussed and concluded in mail thread
(http://www.postgresql.org/message-id/006f01ce34f0$d6fa8220$84ef8660$@kapila
@huawei.com), for moving unused buffer's to freelist end, 

I having implemented the idea and taken some performance data.

 

 

In the attached patch, bgwriter/checkpointer moves unused (usage_count =0 &&
refcount = 0) buffer's to end of freelist. I have implemented a new API
StrategyMoveBufferToFreeListEnd() to 

move buffer's to end of freelist.

 

Performance Data :

 

Configuration Details

O/S - Suse-11

RAM - 24GB

Number of Cores - 8

Server Conf - checkpoint_segments = 256; checkpoint_timeout = 25 min,
synchronous_commit = 0FF, shared_buffers = 5GB

Pgbench - Select-only

Scalefactor - 1200

Time - Each run is of 20 mins

 

Below data is for average 3 runs of 20 minutes

 

                        8C-8T                16C-16T            32C-32T
64C-64T

HEAD               11997               8455                 4989
2757

After Patch        19807               13296               8388
2821

 

Detailed each run data is attached with mail.

 

This is just the initial data, I will collect more data based on different
configuration of shared buffers and other configurations.

 

Feedback/Suggesions?

 

With Regards,

Amit Kapila.

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

  [text/html] move_unused_buffers_to_freelist.htm (23.3K, ../002f01ce50a8$e057c7a0$a10756e0$@kapila@huawei.com/3-move_unused_buffers_to_freelist.htm)
  download | inline:
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 12">
<link rel=File-List href="move_unused_buffers_to_freelist_files/filelist.xml">
<style id="move_unused_buffers_to_freelist_26011_Styles">
<!--table
	{mso-displayed-decimal-separator:"\.";
	mso-displayed-thousand-separator:"\,";}
.xl1526011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6326011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border:.5pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6426011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:.5pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:1.0pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6526011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:.5pt solid windowtext;
	border-right:1.0pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:.5pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6626011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:.5pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:1.0pt solid windowtext;
	border-left:1.0pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6726011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:.5pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:1.0pt solid windowtext;
	border-left:.5pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6826011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:.5pt solid windowtext;
	border-right:1.0pt solid windowtext;
	border-bottom:1.0pt solid windowtext;
	border-left:.5pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6926011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:1.0pt solid windowtext;
	border-left:1.0pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl7026011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:1.0pt solid windowtext;
	border-left:.5pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl7126011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:1.0pt solid windowtext;
	border-bottom:1.0pt solid windowtext;
	border-left:.5pt solid windowtext;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl7226011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:1.0pt solid windowtext;
	background:yellow;
	mso-pattern:black none;
	white-space:nowrap;}
.xl7326011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:.5pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:.5pt solid windowtext;
	background:yellow;
	mso-pattern:black none;
	white-space:nowrap;}
.xl7426011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:1.0pt solid windowtext;
	border-bottom:.5pt solid windowtext;
	border-left:.5pt solid windowtext;
	background:yellow;
	mso-pattern:black none;
	white-space:nowrap;}
.xl7526011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:700;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:none;
	border-bottom:1.0pt solid windowtext;
	border-left:1.0pt solid windowtext;
	background:yellow;
	mso-pattern:black none;
	white-space:normal;}
.xl7626011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:700;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:none;
	border-bottom:1.0pt solid windowtext;
	border-left:none;
	background:yellow;
	mso-pattern:black none;
	white-space:normal;}
.xl7726011
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:windowtext;
	font-size:10.0pt;
	font-weight:700;
	font-style:normal;
	text-decoration:none;
	font-family:Arial, sans-serif;
	mso-font-charset:0;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border-top:1.0pt solid windowtext;
	border-right:1.0pt solid windowtext;
	border-bottom:1.0pt solid windowtext;
	border-left:none;
	background:yellow;
	mso-pattern:black none;
	white-space:normal;}
-->
</style>
</head>

<body>
<!--[if !excel]>&nbsp;&nbsp;<![endif]-->
<!--The following information was generated by Microsoft Office Excel's Publish
as Web Page wizard.-->
<!--If the same item is republished from Excel, all information between the DIV
tags will be replaced.-->
<!----------------------------->
<!--START OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD -->
<!----------------------------->

<div id="move_unused_buffers_to_freelist_26011" align=center
x:publishsource="Excel">

<table border=0 cellpadding=0 cellspacing=0 width=778 style='border-collapse:
 collapse;table-layout:fixed;width:584pt'>
 <col width=64 span=2 style='width:48pt'>
 <col width=138 style='mso-width-source:userset;mso-width-alt:4920;width:104pt'>
 <col width=64 span=8 style='width:48pt'>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 width=64 style='height:13.8pt;width:48pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
  <td class=xl1526011 width=138 style='width:104pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
  <td class=xl1526011 width=64 style='width:48pt'></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td colspan=2 class=xl7526011 width=202 style='border-right:1.0pt solid black;
  width:152pt'>Configuration Used</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011>O/S</td>
  <td class=xl1526011>Suse-11</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011>RAM</td>
  <td class=xl1526011>24GB</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011>Number of Cores</td>
  <td class=xl1526011 align=right>8</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td colspan=9 class=xl1526011>Server Conf: checkpoint_segments - 256,
  checkpoint_timeout = 25 min, synchronous_commit=off</td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011>shared_buffers</td>
  <td class=xl1526011>5GB</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011>pgbench</td>
  <td class=xl1526011 colspan=2>select-only</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011>pgbench-Scale Factor</td>
  <td class=xl1526011 align=right>1200</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td colspan=3 class=xl7526011 width=192 style='border-right:1.0pt solid black;
  width:144pt'>HEAD</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl7226011>Runs/Concurrency</td>
  <td class=xl7326011 style='border-left:none'>8C-8T</td>
  <td class=xl7326011 style='border-left:none'>16C-16T</td>
  <td class=xl7326011 style='border-left:none'>32C-32T</td>
  <td class=xl7426011 style='border-left:none'>64C-64T</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl6426011 style='border-top:none'>Run-1</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>9664</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>7425</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>5106</td>
  <td class=xl6526011 align=right style='border-top:none;border-left:none'>2570</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl6426011 style='border-top:none'>Run-2</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>13081</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>9009</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>4874</td>
  <td class=xl6526011 align=right style='border-top:none;border-left:none'>2713</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl6426011 style='border-top:none'>Run-3</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>13246</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>8932</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>4988</td>
  <td class=xl6526011 align=right style='border-top:none;border-left:none'>2990</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl6626011 style='border-top:none'>Average</td>
  <td class=xl6726011 align=right style='border-top:none;border-left:none'>11997</td>
  <td class=xl6726011 align=right style='border-top:none;border-left:none'>8455</td>
  <td class=xl6726011 align=right style='border-top:none;border-left:none'>4989</td>
  <td class=xl6826011 align=right style='border-top:none;border-left:none'>2757</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td colspan=3 class=xl7526011 width=192 style='border-right:1.0pt solid black;
  width:144pt'>After Patch</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl7226011>Runs/Concurrency</td>
  <td class=xl7326011 style='border-left:none'>8C-8T</td>
  <td class=xl7326011 style='border-left:none'>16C-16T</td>
  <td class=xl7326011 style='border-left:none'>32C-32T</td>
  <td class=xl7426011 style='border-left:none'>64C-64T</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl6426011 style='border-top:none'>Run-1</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>16239</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>11539</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>7395</td>
  <td class=xl6526011 align=right style='border-top:none;border-left:none'>2512</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl6426011 style='border-top:none'>Run-2</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>21408</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>15090</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>8923</td>
  <td class=xl6526011 align=right style='border-top:none;border-left:none'>2870</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl6426011 style='border-top:none'>Run-3</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>21776</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>13261</td>
  <td class=xl6326011 align=right style='border-top:none;border-left:none'>8846</td>
  <td class=xl6526011 align=right style='border-top:none;border-left:none'>3083</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl6626011 style='border-top:none'>Average</td>
  <td class=xl6726011 align=right style='border-top:none;border-left:none'>19807</td>
  <td class=xl6726011 align=right style='border-top:none;border-left:none'>13296</td>
  <td class=xl6726011 align=right style='border-top:none;border-left:none'>8388</td>
  <td class=xl6826011 align=right style='border-top:none;border-left:none'>2821</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.2pt'>
  <td height=18 class=xl1526011 style='height:13.2pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <tr height=18 style='height:13.8pt'>
  <td height=18 class=xl1526011 style='height:13.8pt'></td>
  <td class=xl1526011></td>
  <td class=xl6926011>Diff In %</td>
  <td class=xl7026011 align=right style='border-left:none'>65.09</td>
  <td class=xl7026011 align=right style='border-left:none'>57.25</td>
  <td class=xl7026011 align=right style='border-left:none'>68.12</td>
  <td class=xl7126011 align=right style='border-left:none'>2.3</td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
  <td class=xl1526011></td>
 </tr>
 <![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=138 style='width:104pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
 </tr>
 <![endif]>
</table>

</div>


<!----------------------------->
<!--END OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD-->
<!----------------------------->
</body>

</html>=

  [application/octet-stream] move_unsed_buffers_to_freelist.patch (4.4K, ../002f01ce50a8$e057c7a0$a10756e0$@kapila@huawei.com/4-move_unsed_buffers_to_freelist.patch)
  download | inline diff:
*** a/src/backend/storage/buffer/bufmgr.c
--- b/src/backend/storage/buffer/bufmgr.c
***************
*** 1674,1685 **** SyncOneBuffer(int buf_id, bool skip_recently_used)
  		return result;
  	}
  
! 	if (!(bufHdr->flags & BM_VALID) || !(bufHdr->flags & BM_DIRTY))
  	{
  		/* It's clean, so nothing to do */
  		UnlockBufHdr(bufHdr);
  		return result;
  	}
  
  	/*
  	 * Pin it, share-lock it, write it.  (FlushBuffer will do nothing if the
--- 1674,1703 ----
  		return result;
  	}
  
! 	if (!(bufHdr->flags & BM_VALID))
  	{
  		/* It's clean, so nothing to do */
  		UnlockBufHdr(bufHdr);
  		return result;
  	}
+ 	else if (!(bufHdr->flags & BM_DIRTY))                                   
+  	{
+  		/*
+  		 * It's clean, so nothing to flush;
+  		 * if buffer is unused then move it to freelist
+  		 */
+  		if (bufHdr->refcount == 0 && bufHdr->usage_count == 0)
+  		{
+  		    UnlockBufHdr(bufHdr);
+  			StrategyMoveBufferToFreeListEnd (bufHdr);
+  		}
+  		else
+  		{                                                   
+  			UnlockBufHdr(bufHdr);
+  		}                  
+  		return result;
+  	}                                                             
+ 
  
  	/*
  	 * Pin it, share-lock it, write it.  (FlushBuffer will do nothing if the
***************
*** 1693,1698 **** SyncOneBuffer(int buf_id, bool skip_recently_used)
--- 1711,1730 ----
  	LWLockRelease(bufHdr->content_lock);
  	UnpinBuffer(bufHdr, true);
  
+ 	/*
+  	 * check if buffer is not used actively by any backend, then move it to freelist
+  	 */
+  	LockBufHdr(bufHdr);            
+  	if (bufHdr->refcount == 0 && bufHdr->usage_count == 0)
+  	{                                          
+  		UnlockBufHdr(bufHdr);                    
+  		StrategyMoveBufferToFreeListEnd (bufHdr);
+  	}                                                                           
+  	else
+  	{                                          
+  		UnlockBufHdr(bufHdr);
+  	}
+ 
  	return result | BUF_WRITTEN;
  }
  
*** a/src/backend/storage/buffer/freelist.c
--- b/src/backend/storage/buffer/freelist.c
***************
*** 259,264 **** StrategyFreeBuffer(volatile BufferDesc *buf)
--- 259,298 ----
  }
  
  /*
+  * StrategyMoveBufferToFreeListEnd: put a buffer on the end of freelist
+  */                                                                                      
+ void
+ StrategyMoveBufferToFreeListEnd(volatile BufferDesc *buf)                                
+ {
+ 	LWLockAcquire(BufFreelistLock, LW_EXCLUSIVE);                                    
+                                                                                          
+  	/*
+  	 * It is possible that we are told to put something in the freelist that
+  	 * is already in it; don't screw up the list if so.
+  	 */                    
+  	if (buf->freeNext == FREENEXT_NOT_IN_LIST)
+  	{                   
+  		/*
+  		 * put the buffer on end of list and if list is empty then
+  		 * assign first and last freebuffer with this buffer id.             
+  		 */     
+  		buf->freeNext = FREENEXT_END_OF_LIST;
+  		if (StrategyControl->firstFreeBuffer < 0)                                
+  		{                
+  			StrategyControl->firstFreeBuffer = buf->buf_id;
+  			StrategyControl->lastFreeBuffer = buf->buf_id;                   
+  			LWLockRelease(BufFreelistLock);              
+  			return;                      
+  		}                                                         
+  		BufferDescriptors[StrategyControl->lastFreeBuffer].freeNext = buf->buf_id;
+  		StrategyControl->lastFreeBuffer = buf->buf_id;
+  	}         
+                                                                                          
+  	LWLockRelease(BufFreelistLock);
+ }                                                                                        
+ 
+ 
+ /*
   * StrategySyncStart -- tell BufferSync where to start syncing
   *
   * The result is the buffer index of the best buffer to sync first.
*** a/src/include/storage/buf_internals.h
--- b/src/include/storage/buf_internals.h
***************
*** 185,190 **** extern BufferDesc *LocalBufferDescriptors;
--- 185,191 ----
  extern volatile BufferDesc *StrategyGetBuffer(BufferAccessStrategy strategy,
  				  bool *lock_held);
  extern void StrategyFreeBuffer(volatile BufferDesc *buf);
+ extern void StrategyMoveBufferToFreeListEnd(volatile BufferDesc *buf);
  extern bool StrategyRejectBuffer(BufferAccessStrategy strategy,
  					 volatile BufferDesc *buf);
  
=

view thread (39+ messages)  latest in thread

Message-ID: <002f01ce50a8$e057c7a0$a10756e0$@kapila@huawei.com>
Permalink:  ../002f01ce50a8$e057c7a0$a10756e0$@kapila@huawei.com/
Also on:    postgresql.org/message-id/002f01ce50a8$e057c7a0$a10756e0$@kapila@huawei.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: amit.kapila@huawei.com
  Subject: Re: Move unused buffers to freelist
  In-Reply-To: <002f01ce50a8$e057c7a0$a10756e0$@kapila@huawei.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox