Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Avoid calling sysconf for every file loaded.



details:   https://anonhg.NetBSD.org/src/rev/17c84824a1e6
branches:  trunk
changeset: 830003:17c84824a1e6
user:      sjg <sjg%NetBSD.org@localhost>
date:      Thu Feb 22 01:59:28 2018 +0000

description:
Avoid calling sysconf for every file loaded.
At start of a meta build this can be measurable overhead.

Patch from bdrewery at freebsd.org

diffstat:

 usr.bin/make/parse.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r 9b61d8a32da1 -r 17c84824a1e6 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Thu Feb 22 01:50:26 2018 +0000
+++ b/usr.bin/make/parse.c      Thu Feb 22 01:59:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.226 2018/02/12 21:38:09 sjg Exp $  */
+/*     $NetBSD: parse.c,v 1.227 2018/02/22 01:59:28 sjg Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.226 2018/02/12 21:38:09 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.227 2018/02/22 01:59:28 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c    8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.226 2018/02/12 21:38:09 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.227 2018/02/22 01:59:28 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -481,7 +481,7 @@
 loadfile(const char *path, int fd)
 {
        struct loadedfile *lf;
-       long pagesize;
+       static long pagesize = 0;
        ssize_t result;
        size_t bufpos;
 
@@ -503,7 +503,8 @@
 
        if (load_getsize(fd, &lf->len) == SUCCESS) {
                /* found a size, try mmap */
-               pagesize = sysconf(_SC_PAGESIZE);
+               if (pagesize == 0)
+                       pagesize = sysconf(_SC_PAGESIZE);
                if (pagesize <= 0) {
                        pagesize = 0x1000;
                }



Home | Main Index | Thread Index | Old Index