Re: WAL: O_DIRECT and multipage-writer

Lists: pgsql-hackerspgsql-patches
From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: WAL: O_DIRECT and multipage-writer
Date: 2005-01-25 09:06:23
Message-ID: 20050125164005.BC8A.ITAGAKI.TAKAHIRO@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hello, all.

I think that there is room for improvement in WAL.
Here is a patch for it.
- Multiple pages are written in one write() if it is contiguous.
- Add 'open_direct' to wal_sync_method.

WAL writer writes one page in one write(). This is not efficient
when wal_sync_method is 'open_sync', because the writer waits for
IO completions at each write(). Multipage-writer can reduce syscalls
and improve IO throughput.

'open_direct' uses O_DIRECT instead of O_SYNC. O_DIRECT implies synchronous
writing, so it may show the tendency like open_sync. But maybe it can reduce
memcpy() and save OS's disk cache memory.

I benchmarked this patch with pgbench. It works well and
improved 50% of tps on my machine. WAL seems to be bottle-neck
on machines with poor disks.

This patch has not yet tested enough. I would like it to be examined much
and taken into PostgreSQL.

There are still many TODOs:
* Is this logic really correct?
- O_DIRECT_BUFFER_ALIGN should be adjusted to runtime, not compile time.
- Consider to use writev() instead of write().
Buffers are noncontiguous when WAL ring buffer rotates.
- If wan_sync_method is not open_direct, XLOG_EXTRA_BUFFERS can be 0.

Sincerely,
ITAGAKI Takahiro

-- pgbench result --

$ ./pgbench -s 100 -c 50 -t 400

- 8.0.0 default + fsync:
tps = 20.630632 (including connections establishing)
tps = 20.636768 (excluding connections establishing)
- multipage-writer + open_direct:
tps = 33.761917 (including connections establishing)
tps = 33.778320 (excluding connections establishing)

Environment:
OS : Linux kernel 2.6.9
CPU : Pentium 4 3GHz
disk : ATA 5400rpm (Data and WAL are placed on same partition.)
memory : 1GB
config : shared_buffers=10000, wal_buffers=256,
XLOG_SEG_SIZE=256MB, checkpoint_segment=4

---
ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
NTT Cyber Space Laboratories
Nippon Telegraph and Telephone Corporation.

Attachment Content-Type Size
xlog.diff application/octet-stream 5.9 KB

From: "Michael Paesold" <mpaesold(at)gmx(dot)at>
To: "ITAGAKI Takahiro" <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: WAL: O_DIRECT and multipage-writer
Date: 2005-01-25 09:30:01
Message-ID: 015301c502c0$730d1220$ad01a8c0@zaphod
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

ITAGAKI Takahiro wrote:

> I think that there is room for improvement in WAL.
> Here is a patch for it.

I think you should resend your patch as a context diff (diff -c). Otherwise
it's hard to see what your patch does.

Best Regards,
Michael Paesold


From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: WAL: O_DIRECT and multipage-writer
Date: 2005-01-25 10:33:40
Message-ID: 20050125192156.BC9C.ITAGAKI.TAKAHIRO@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Excuse me.
I resend the patch with diff -c.

On Tue, 25 Jan 2005 10:30:01 +0100
"Michael Paesold" <mpaesold(at)gmx(dot)at> wrote:

> ITAGAKI Takahiro wrote:
>
> > I think that there is room for improvement in WAL.
> > Here is a patch for it.
>
> I think you should resend your patch as a context diff (diff -c). Otherwise
> it's hard to see what your patch does.

---
ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
NTT Cyber Space Laboratories
Nippon Telegraph and Telephone Corporation.

Attachment Content-Type Size
xlog.c.diff application/octet-stream 10.9 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: WAL: O_DIRECT and multipage-writer
Date: 2005-01-25 15:56:38
Message-ID: 3763.1106668598@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp> writes:
> I resend the patch with diff -c.

What does XLOG_EXTRA_BUFFERS accomplish?

Also, I'm worried that you broke something by not updating
Write->curridx immediately in XLogWrite. There certainly isn't going
to be any measurable performance boost from keeping that in a local
variable, so why take any risk?

regards, tom lane


From: ITAGAKI Takahiro <itagaki(at)tiara(dot)ocn(dot)ne(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: WAL: O_DIRECT and multipage-writer
Date: 2005-01-26 13:06:46
Message-ID: 20050126203831.8736.ITAGAKI@tiara.ocn.ne.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> What does XLOG_EXTRA_BUFFERS accomplish?

It is because the buffer passed to direct-io must be aligned to
the same size of filesystem page, typically 4KB. Buffers allocated
with ShmemInitStruct are not necessarily aligned, so we need to allocate
extra buffers and align them by ourself.

> Also, I'm worried that you broke something by not updating
> Write->curridx immediately in XLogWrite. There certainly isn't going
> to be any measurable performance boost from keeping that in a local
> variable, so why take any risk?

Keeping Write->curridx in a local variable is not for performance,
but for writing multiple pages at once.
I think it is ok to update Write->curridx at the end of XLogWrite,
because XLogCtl.Write.curridx will be touched by only one process
at a time. Process-shared variables are not modified until XLogWrite
is completed, so that other backends can write same contents later
even if the backend in XLogWrite is crushed.

Sincerely,
ITAGAKI Takahiro


From: Mark Wong <markw(at)osdl(dot)org>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] WAL: O_DIRECT and multipage-writer
Date: 2005-01-27 18:18:44
Message-ID: 20050127101844.A29667@osdl.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hi everyone,

I gave this a try with DBT-2, but got a core dump on our ia64 system.
I hope this isn't a random thing, like I ran into previously. Maybe
I'll try again, but postgres dumped core. Binary and core here:
http://developer.osdl.org/markw/pgsql/core/2morefiles.tar.bz2

#0 FunctionCall2 (flinfo=0x0, arg1=0, arg2=0) at fmgr.c:1141
1141 result = FunctionCallInvoke(&fcinfo);
(gdb) bt
#0 FunctionCall2 (flinfo=0x0, arg1=0, arg2=0) at fmgr.c:1141
#1 0x40000000003bdb80 in FunctionCall2 (flinfo=Cannot access memory at address 0x0
) at fmgr.c:1141
#2 0x40000000003bdb80 in FunctionCall2 (flinfo=Cannot access memory at address 0x0
) at fmgr.c:1141

Over and over again, so I'll keep the backtrace short.

Mark


From: ITAGAKI Takahiro <itagaki(at)tiara(dot)ocn(dot)ne(dot)jp>
To: Mark Wong <markw(at)osdl(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] WAL: O_DIRECT and multipage-writer
Date: 2005-01-27 21:28:32
Message-ID: 20050128061624.D037.ITAGAKI@tiara.ocn.ne.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Thanks for testing, Mark!

> I gave this a try with DBT-2, but got a core dump on our ia64 system.
> I hope this isn't a random thing, like I ran into previously. Maybe
> I'll try again, but postgres dumped core.

Sorry, this seems to be my patch's bug.
Which datatype did you compile with? LP64, ILP64, or LLP64?
If you used LLP64, I think the cause is buffer alignment routine
because of sizeof(long) != sizeof(void*).

I'll fix it soon...

ITAGAKI Takahiro


From: Mark Wong <markw(at)osdl(dot)org>
To: ITAGAKI Takahiro <itagaki(at)tiara(dot)ocn(dot)ne(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] WAL: O_DIRECT and multipage-writer
Date: 2005-01-27 21:30:25
Message-ID: 20050127133025.A2228@osdl.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hmm... I don't remember specifying a datatype. I suppose whatever the
default one is. :)

I'll be happy to test again, just let me know.

Mark

On Fri, Jan 28, 2005 at 06:28:32AM +0900, ITAGAKI Takahiro wrote:
> Thanks for testing, Mark!
>
> > I gave this a try with DBT-2, but got a core dump on our ia64 system.
> > I hope this isn't a random thing, like I ran into previously. Maybe
> > I'll try again, but postgres dumped core.
>
> Sorry, this seems to be my patch's bug.
> Which datatype did you compile with? LP64, ILP64, or LLP64?
> If you used LLP64, I think the cause is buffer alignment routine
> because of sizeof(long) != sizeof(void*).
>
> I'll fix it soon...
>
>
> ITAGAKI Takahiro


From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCHES] WAL: O_DIRECT and multipage-writer (+ memory leak)
Date: 2005-02-03 10:25:55
Message-ID: 20050203181338.9BDF.ITAGAKI.TAKAHIRO@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hello everyone.

I fixed two bugs in the patch that I sent before.
Check and test new one, please.

1. Fix update timing of Write->curridx. (pointed by Tom)
Change to update it soon after write().

2. Fix buffer alignment routine on 64bit cpu. (pointed by Mark)
I checked it on Xeon EM64T and it worked properly, but I don't have IA64...

BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc()
is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it.
(But this leak is not serious, because this function is called only once.)

ITAGAKI Takahiro

Attachment Content-Type Size
xlog.c.diff application/octet-stream 12.5 KB

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: WAL: O_DIRECT and multipage-writer
Date: 2005-02-14 23:25:04
Message-ID: 200502142325.j1ENP4e19810@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


This thread has been saved for the 8.1 release:

http://momjian.postgresql.org/cgi-bin/pgpatches2

---------------------------------------------------------------------------

ITAGAKI Takahiro wrote:
> Hello, all.
>
> I think that there is room for improvement in WAL.
> Here is a patch for it.
> - Multiple pages are written in one write() if it is contiguous.
> - Add 'open_direct' to wal_sync_method.
>
> WAL writer writes one page in one write(). This is not efficient
> when wal_sync_method is 'open_sync', because the writer waits for
> IO completions at each write(). Multipage-writer can reduce syscalls
> and improve IO throughput.
>
> 'open_direct' uses O_DIRECT instead of O_SYNC. O_DIRECT implies synchronous
> writing, so it may show the tendency like open_sync. But maybe it can reduce
> memcpy() and save OS's disk cache memory.
>
> I benchmarked this patch with pgbench. It works well and
> improved 50% of tps on my machine. WAL seems to be bottle-neck
> on machines with poor disks.
>
> This patch has not yet tested enough. I would like it to be examined much
> and taken into PostgreSQL.
>
> There are still many TODOs:
> * Is this logic really correct?
> - O_DIRECT_BUFFER_ALIGN should be adjusted to runtime, not compile time.
> - Consider to use writev() instead of write().
> Buffers are noncontiguous when WAL ring buffer rotates.
> - If wan_sync_method is not open_direct, XLOG_EXTRA_BUFFERS can be 0.
>
>
> Sincerely,
> ITAGAKI Takahiro
>
>
>
> -- pgbench result --
>
> $ ./pgbench -s 100 -c 50 -t 400
>
> - 8.0.0 default + fsync:
> tps = 20.630632 (including connections establishing)
> tps = 20.636768 (excluding connections establishing)
> - multipage-writer + open_direct:
> tps = 33.761917 (including connections establishing)
> tps = 33.778320 (excluding connections establishing)
>
> Environment:
> OS : Linux kernel 2.6.9
> CPU : Pentium 4 3GHz
> disk : ATA 5400rpm (Data and WAL are placed on same partition.)
> memory : 1GB
> config : shared_buffers=10000, wal_buffers=256,
> XLOG_SEG_SIZE=256MB, checkpoint_segment=4
>
> ---
> ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
> NTT Cyber Space Laboratories
> Nippon Telegraph and Telephone Corporation.

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCHES] WAL: O_DIRECT and multipage-writer (+ memory
Date: 2005-02-15 04:08:18
Message-ID: 200502150408.j1F48IQ13644@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


This has been saved for the 8.1 release:

http://momjian.postgresql.org/cgi-bin/pgpatches2

---------------------------------------------------------------------------

ITAGAKI Takahiro wrote:
> Hello everyone.
>
> I fixed two bugs in the patch that I sent before.
> Check and test new one, please.
>
> 1. Fix update timing of Write->curridx. (pointed by Tom)
> Change to update it soon after write().
>
> 2. Fix buffer alignment routine on 64bit cpu. (pointed by Mark)
> I checked it on Xeon EM64T and it worked properly, but I don't have IA64...
>
>
> BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc()
> is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it.
> (But this leak is not serious, because this function is called only once.)
>
>
> ITAGAKI Takahiro

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Mark Wong <markw(at)osdl(dot)org>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCHES] WAL: O_DIRECT and multipage-writer (+ memory leak)
Date: 2005-03-01 21:53:10
Message-ID: 20050301215310.GD2115@osdl.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, Feb 03, 2005 at 07:25:55PM +0900, ITAGAKI Takahiro wrote:
> Hello everyone.
>
> I fixed two bugs in the patch that I sent before.
> Check and test new one, please.

Ok, finally got back into the office and was able to run 1 set of
tests.

So the new baseline result with 8.0.1:
http://www.osdl.org/projects/dbt2dev/results/dev4-010/309/
Throughput: 3639.97

Results with the patch but open_direct not set:
http://www.osdl.org/projects/dbt2dev/results/dev4-010/308/
Throughput: 3494.72

Results with the patch and open_direct set:
http://www.osdl.org/projects/dbt2dev/results/dev4-010/312/
Throughput: 3489.69

You can verify that the wall_sync_method is set to open_direct under
the "database parameters" link, but I'm wondering if I missed
something. It looks a little odd the the performance dropped.

Mark


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Mark Wong <markw(at)osdl(dot)org>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCHES] WAL: O_DIRECT and multipage-writer (+
Date: 2005-03-11 09:55:35
Message-ID: 1110534935.6117.472.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Tue, 2005-03-01 at 13:53 -0800, Mark Wong wrote:
> On Thu, Feb 03, 2005 at 07:25:55PM +0900, ITAGAKI Takahiro wrote:
> > Hello everyone.
> >
> > I fixed two bugs in the patch that I sent before.
> > Check and test new one, please.
>
> Ok, finally got back into the office and was able to run 1 set of
> tests.
>
> So the new baseline result with 8.0.1:
> http://www.osdl.org/projects/dbt2dev/results/dev4-010/309/
> Throughput: 3639.97
>
> Results with the patch but open_direct not set:
> http://www.osdl.org/projects/dbt2dev/results/dev4-010/308/
> Throughput: 3494.72
>
> Results with the patch and open_direct set:
> http://www.osdl.org/projects/dbt2dev/results/dev4-010/312/
> Throughput: 3489.69
>
> You can verify that the wall_sync_method is set to open_direct under
> the "database parameters" link, but I'm wondering if I missed
> something. It looks a little odd the the performance dropped.

Is there anything more to say on this?
Is it case-closed, or is there further work underway - I can't see any
further chat on this thread.

These results show it doesn't work better on larger systems. The
original testing showed it worked better on smaller systems - is there
still scope to include this for smaller configs?

If not, thanks for taking the time to write the patch and investigate
whether changes in this area would help. Not every performance patch
improves things, but that doesn't mean we shouldn't try...

Best Regards, Simon Riggs


From: Mark Wong <markw(at)osdl(dot)org>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: WAL: O_DIRECT and multipage-writer
Date: 2005-03-22 22:30:13
Message-ID: 20050322223013.GC12885@osdl.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Tue, Jan 25, 2005 at 06:06:23PM +0900, ITAGAKI Takahiro wrote:
> Environment:
> OS : Linux kernel 2.6.9
> CPU : Pentium 4 3GHz
> disk : ATA 5400rpm (Data and WAL are placed on same partition.)
> memory : 1GB
> config : shared_buffers=10000, wal_buffers=256,
> XLOG_SEG_SIZE=256MB, checkpoint_segment=4

Hi Itagaki,

In light of this thread, have you compared the performance on
Linux-2.4?

Direct io on block device has performance regression on 2.6.x kernel
http://www.ussg.iu.edu/hypermail/linux/kernel/0503.1/0328.html

Mark


From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
To: Mark Wong <markw(at)osdl(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: WAL: O_DIRECT and multipage-writer
Date: 2005-03-23 04:55:46
Message-ID: 20050323134912.387C.ITAGAKI.TAKAHIRO@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hi, Mark.

Mark Wong <markw(at)osdl(dot)org> wrote:

> In light of this thread, have you compared the performance on
> Linux-2.4?

No, but I'm just testing my patch on Linux-2.4 with a middle-range server.
I will report the results sometime soon.

By the way, I found the debug option (XLOG_MULTIPAGE_WRITER_DEBUG) was enabled
in your prior benchmarks. It writes logs a lot.
I hope performance doesn't fall at least without debug.

> So the new baseline result with 8.0.1:
> Throughput: 3639.97
> Results with the patch but open_direct not set:
> Throughput: 3494.72
> Results with the patch and open_direct set:
> Throughput: 3489.69

---
ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
NTT Cyber Space Laboratories


From: Mark Wong <markw(at)osdl(dot)org>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: WAL: O_DIRECT and multipage-writer
Date: 2005-03-23 23:59:20
Message-ID: 20050323235920.GA8864@osdl.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Wed, Mar 23, 2005 at 01:55:46PM +0900, ITAGAKI Takahiro wrote:
> Hi, Mark.
>
> Mark Wong <markw(at)osdl(dot)org> wrote:
>
> > In light of this thread, have you compared the performance on
> > Linux-2.4?
>
> No, but I'm just testing my patch on Linux-2.4 with a middle-range server.
> I will report the results sometime soon.
>
>
> By the way, I found the debug option (XLOG_MULTIPAGE_WRITER_DEBUG) was enabled
> in your prior benchmarks. It writes logs a lot.
> I hope performance doesn't fall at least without debug.

That's 'log_min_messages = debug1' right? Maybe I should give it
another go with that set back to the default.

Thanks,
Mark


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory
Date: 2005-06-05 03:40:48
Message-ID: 200506050340.j553emJ06333@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

ITAGAKI Takahiro wrote:
> Hello everyone.
>
> I fixed two bugs in the patch that I sent before.
> Check and test new one, please.
>
> 1. Fix update timing of Write->curridx. (pointed by Tom)
> Change to update it soon after write().
>
> 2. Fix buffer alignment routine on 64bit cpu. (pointed by Mark)
> I checked it on Xeon EM64T and it worked properly, but I don't have IA64...
>
>
> BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc()
> is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it.
> (But this leak is not serious, because this function is called only once.)

Does the following patch fix the memory leak you described?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 519 bytes

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>, Mark Wong <markw(at)osdl(dot)org>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+
Date: 2005-06-05 03:42:51
Message-ID: 200506050342.j553gp506678@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


Yes, I assume that the patch to group the writes isn't something we want
right now, and the one for O_DIRECT is going to need an additional
fsync, and I have asked for testing on that.

I have posted a patch that I think fixes the memory leak reported and am
waiting for feedback on that.

---------------------------------------------------------------------------

Simon Riggs wrote:
> On Tue, 2005-03-01 at 13:53 -0800, Mark Wong wrote:
> > On Thu, Feb 03, 2005 at 07:25:55PM +0900, ITAGAKI Takahiro wrote:
> > > Hello everyone.
> > >
> > > I fixed two bugs in the patch that I sent before.
> > > Check and test new one, please.
> >
> > Ok, finally got back into the office and was able to run 1 set of
> > tests.
> >
> > So the new baseline result with 8.0.1:
> > http://www.osdl.org/projects/dbt2dev/results/dev4-010/309/
> > Throughput: 3639.97
> >
> > Results with the patch but open_direct not set:
> > http://www.osdl.org/projects/dbt2dev/results/dev4-010/308/
> > Throughput: 3494.72
> >
> > Results with the patch and open_direct set:
> > http://www.osdl.org/projects/dbt2dev/results/dev4-010/312/
> > Throughput: 3489.69
> >
> > You can verify that the wall_sync_method is set to open_direct under
> > the "database parameters" link, but I'm wondering if I missed
> > something. It looks a little odd the the performance dropped.
>
> Is there anything more to say on this?
> Is it case-closed, or is there further work underway - I can't see any
> further chat on this thread.
>
> These results show it doesn't work better on larger systems. The
> original testing showed it worked better on smaller systems - is there
> still scope to include this for smaller configs?
>
> If not, thanks for taking the time to write the patch and investigate
> whether changes in this area would help. Not every performance patch
> improves things, but that doesn't mean we shouldn't try...
>
> Best Regards, Simon Riggs
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory
Date: 2005-06-05 04:45:32
Message-ID: 855.1117946732@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc()
>> is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it.
>> (But this leak is not serious, because this function is called only once.)

> Does the following patch fix the memory leak you described?

You realize this is a waste of code, no? It's not like the bootstrap
subprocess frees every single bit of memory it ever allocates, and even
less like it'd be profitable to try to make it do so ... the memory
will go away anyway when the subprocess exits.

regards, tom lane


From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>
To: pgsql-patches(at)postgresql(dot)org
Subject: Memory leak in BootStrapXLOG()
Date: 2005-06-06 06:53:27
Message-ID: 20050606152420.41C8.ITAGAKI.TAKAHIRO@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:

> > BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc()
> > is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it.
> > (But this leak is not serious, because this function is called only once.)
>
> Does the following patch fix the memory leak you described?

Yes, the revised patch has no leak by using stack instead of malloc().
This leak is trivial, but anyway direct io needs an aligned buffer.
IMHO any of the following is ok.

[A] 1st patch
char *buffer;
void* buffer0;
buffer0 = malloc(BLCKSZ + XLOG_EXTRA_BUFFERS);
buffer = (char *) XLOG_BUFFERS_ALIGN(buffer0);
free(buffer0);

[B] 2nd patch
char *buffer;
char buffer0[BLCKSZ + XLOG_EXTRA_BUFFERS + MAXIMUM_ALIGNOF];
buffer = XLOG_BUFFERS_ALIGN(buffer0);

[C] following code is simple if we don't care the memory leak.
char *buffer;
buffer = XLOG_BUFFERS_ALIGN( malloc(BLCKSZ + XLOG_EXTRA_BUFFERS) );

---
ITAGAKI Takahiro
NTT Cyber Space Laboratories


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory
Date: 2005-06-06 13:35:54
Message-ID: 200506061335.j56DZs721211@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> >> BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc()
> >> is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it.
> >> (But this leak is not serious, because this function is called only once.)
>
> > Does the following patch fix the memory leak you described?
>
> You realize this is a waste of code, no? It's not like the bootstrap
> subprocess frees every single bit of memory it ever allocates, and even
> less like it'd be profitable to try to make it do so ... the memory
> will go away anyway when the subprocess exits.

I guess, but the person reported a leak so I figured I would fix it.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: ITAGAKI Takahiro <itagaki(dot)takahiro(at)lab(dot)ntt(dot)co(dot)jp>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory
Date: 2005-06-06 13:56:30
Message-ID: 25394.1118066190@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Tom Lane wrote:
>> You realize this is a waste of code, no?

> I guess, but the person reported a leak so I figured I would fix it.

I don't really care whether there's a free() there or not --- what
bothers me is that calling it a leak shows a fundamental
misunderstanding of the environment in which that code runs, which
is likely to lead to proposed changes that have less trivial
consequences.

regards, tom lane