simplify register_dirty_segment()

From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: simplify register_dirty_segment()
Date: 2005-04-25 08:13:39
Message-ID: d4i8vq$tfe$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The basic idea is to change register_dirty_segment() to
register_opened_segment().

That is, we don't care if a segment is dirty or not, if someone opened it,
then we will fsync it at checkpoint time. Currently,
register_dirty_segment() is called in mdextend(), mdwrite() and
mdtruncate(), this is costly since ForwardFsyncRequest() has to grab the
BgWriterCommLock lock exclusively each time and mdwrite() is quite frequent.

Benefits:
+ reduce BgWriterCommLock lock contention;
+ simplify code - we just need to register_opened_segment() when we open the
segment;
+ reduce the BgWriterShmem->requests[] size;

Costs:
+ have to fsync() a file even if we made no modification on it. The cost is
just open/close file, so I think this is acceptable;

Corner case:
+ what if we run out of shared memory for ForwardFsyncRequest()? In the
original way, we just fsync() the file ourselves; Now we can't do this.
Instead, we will issue and wait a checkpoint request to Bgwriter(let him
absorb the requests) and try ForwardFsyncRequest() again.

Comments?

Regards,
Qingqing

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-04-25 08:43:16 Re: simplify register_dirty_segment()
Previous Message Christopher Kings-Lynne 2005-04-25 07:38:22 Re: Passwords in PSQL