Re: [HACKERS] TODO item

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

> 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?

Can you be more specific. How does fsync work now vs. your proposed
change. I did not see that here. Sorry.

>
> 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;
> ! }
> ! }
> }
>
> /*
>

--
Bruce Momjian | http://www.op.net/~candle
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2000-02-06 08:36:55 RE: [HACKERS] TODO item
Previous Message Tatsuo Ishii 2000-02-06 06:40:59 Re: [HACKERS] TODO item