Re: [HACKERS] TODO item

From: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
To: pgman(at)candle(dot)pha(dot)pa(dot)us
Cc: t-ishii(at)sra(dot)co(dot)jp, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] TODO item
Date: 2000-02-06 06:40:59
Message-ID: 20000206154059U.t-ishii@sra.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > In the TODO file:
> >
> > * -Allow transaction commits with rollback with no-fsync performance [fsync](Vadim)
> >
> > Has this been done in current? I see almost no performance
> > improvement on copying data into a table.
>
> TODO updated. That was part of MVCC which originally was supposed to be
> in 7.0.

Thanks.

BTW, I have worked a little bit on this item. The idea is pretty
simple. Instead of doing a real fsync() in pg_fsync(), just marking it
so that we remember to do fsync() at the commit time. Following
patches illustrate the idea. An experience shows that it dramatically
boosts the performance of copy. Unfortunately I see virtually no
difference for TPC-B like small many concurrent transactions. Maybe we
would need WAL for this. Comments?

Index: access/transam/xact.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/access/transam/xact.c,v
retrieving revision 1.60
diff -c -r1.60 xact.c
*** access/transam/xact.c 2000/01/29 16:58:29 1.60
--- access/transam/xact.c 2000/02/06 06:12:58
***************
*** 639,644 ****
--- 639,646 ----
if (SharedBufferChanged)
{
FlushBufferPool();
+ pg_fsync_pending();
+
if (leak)
ResetBufferPool();

***************
*** 653,658 ****
--- 655,661 ----
*/
leak = BufferPoolCheckLeak();
FlushBufferPool();
+ pg_fsync_pending();
}

if (leak)
Index: storage/file/fd.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/storage/file/fd.c,v
retrieving revision 1.52
diff -c -r1.52 fd.c
*** storage/file/fd.c 2000/01/26 05:56:55 1.52
--- storage/file/fd.c 2000/02/06 06:13:01
***************
*** 189,202 ****
static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
static char *filepath(char *filename);
static long pg_nofile(void);

/*
* pg_fsync --- same as fsync except does nothing if -F switch was given
*/
int
pg_fsync(int fd)
{
! return disableFsync ? 0 : fsync(fd);
}

/*
--- 189,238 ----
static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode);
static char *filepath(char *filename);
static long pg_nofile(void);
+ static void alloc_fsync_info(void);

+ static char *fsync_request;
+ static int nfds;
+
/*
* pg_fsync --- same as fsync except does nothing if -F switch was given
*/
int
pg_fsync(int fd)
+ {
+ if (fsync_request == NULL)
+ alloc_fsync_info();
+ fsync_request[fd] = 1;
+ return 0;
+ }
+
+ static void alloc_fsync_info(void)
+ {
+ nfds = pg_nofile();
+ fsync_request = malloc(nfds);
+ if (fsync_request == NULL) {
+ elog(ERROR, "alloc_fsync_info: cannot allocate memory");
+ return;
+ }
+ }
+
+ void
+ pg_fsync_pending(void)
{
! int i;
!
! if (disableFsync)
! return;
!
! if (fsync_request == NULL)
! alloc_fsync_info();
!
! for (i=0;i<nfds;i++) {
! if (fsync_request[i]) {
! fsync(i);
! fsync_request[i] = 0;
! }
! }
}

/*

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2000-02-06 06:55:26 Re: [HACKERS] TODO item
Previous Message Tatsuo Ishii 2000-02-06 06:40:03 Re: [HACKERS] pg_ctl man page