From: Guillermo J. Rozas Date: Mon, 10 Aug 1987 21:25:07 +0000 (+0000) Subject: Use prealloc to improve performance of sequential reads/writes. X-Git-Tag: 20090517-FFI~13166 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=57b80ccbf81df5ab4999c94f8215c58f4f557767;p=mit-scheme.git Use prealloc to improve performance of sequential reads/writes. Cache the current disk position to avoid lseek if the next read/write is sequential. --- diff --git a/v7/src/microcode/bchmmg.c b/v7/src/microcode/bchmmg.c index 0ac2c6eca..3e0e84465 100644 --- a/v7/src/microcode/bchmmg.c +++ b/v7/src/microcode/bchmmg.c @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchmmg.c,v 9.34 1987/08/06 06:05:47 cph Exp $ */ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/bchmmg.c,v 9.35 1987/08/10 21:25:07 jinx Exp $ */ /* Memory management top level. Garbage collection to disk. @@ -104,11 +104,13 @@ Pointer *free_buffer_top, *free_buffer_bottom; extern char *mktemp(); int gc_file; +static long current_disk_position; static char *gc_file_name; static char gc_default_file_name[FILE_NAME_LENGTH] = GC_DEFAULT_FILE_NAME; void -open_gc_file() +open_gc_file(size) + int size; { int position; int flags; @@ -151,6 +153,14 @@ open_gc_file() fprintf(stderr, "Aborting.\n"); exit(1); } +#ifdef hpux + if (gc_file_name == gc_default_file_name) + { + extern prealloc(); + prealloc(gc_file, size); + } +#endif + current_disk_position = 0; return; } @@ -233,7 +243,7 @@ Setup_Memory(Our_Heap_Size, Our_Stack_Size, Our_Constant_Size) Heap_Bottom = Heap; Clear_Memory(Our_Heap_Size, Our_Stack_Size, Our_Constant_Size); - open_gc_file(); + open_gc_file(Our_Heap_Size * sizeof(Pointer)); return; } @@ -253,7 +263,8 @@ dump_buffer(from, position, nbuffers, name, success) { long bytes_written; - if (lseek(gc_file, *position, 0) == -1) + if ((current_disk_position != *position) && + (lseek(gc_file, *position, 0) == -1)) { if (success == NULL) { @@ -280,6 +291,7 @@ dump_buffer(from, position, nbuffers, name, success) } *position += bytes_written; + current_disk_position = *position; return; } @@ -292,7 +304,8 @@ load_buffer(position, to, nbytes, name) { long bytes_read; - if (lseek(gc_file, position, 0) == -1) + if ((current_disk_position != position) && + (lseek(gc_file, position, 0) == -1)) { fprintf(stderr, "\nCould not position GC file to read %s.\n", name); Microcode_Termination(TERM_EXIT); @@ -304,6 +317,7 @@ load_buffer(position, to, nbytes, name) Microcode_Termination(TERM_EXIT); /*NOTREACHED*/ } + current_disk_position += bytes_read; return; }