Re: [HACKERS] TODO item - Mailing list pgsql-hackers
From | Bruce Momjian |
---|---|
Subject | Re: [HACKERS] TODO item |
Date | |
Msg-id | 200002060655.BAA09293@candle.pha.pa.us Whole thread Raw |
In response to | Re: [HACKERS] TODO item (Tatsuo Ishii <t-ishii@sra.co.jp>) |
Responses |
Re: [HACKERS] TODO item
|
List | 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@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
pgsql-hackers by date: