aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mansearch.h
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-11 15:46:52 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-11 15:46:52 +0000
commit942615efa992545faa398298d17b66a1c46b5500 (patch)
treee6872639f4715e9faa5f3fd4b577f6cbf14b8346 /mansearch.h
parent27c8079fded40c4d4345acd5aee489d29bb14470 (diff)
downloadmandoc-942615efa992545faa398298d17b66a1c46b5500.tar.gz
mandoc-942615efa992545faa398298d17b66a1c46b5500.tar.zst
mandoc-942615efa992545faa398298d17b66a1c46b5500.zip
Further apropos(1) speed optimization was trickier than anticipated.
Contrary to what i initially thought, almost all time is now spent inside sqlite3(3) routines, and i found no easy way calling less of them. However, sqlite(3) spends substantial time in malloc(3), and even more (twice that) in its immediate malloc wrapper, sqlite3MemMalloc(), keeping track of all individual malloc chunk sizes. Typically about 90% of the malloced memory is used for purposes of the pagecache. By providing an mmap(3) MAP_ANON SQLITE_CONFIG_PAGECACHE, execution time decreases by 20-25% for simple (Nd and/or Nm) queries, 10-20% for non-NAME queries, and even apropos(1) resident memory size as reported by top(1) decreases by 20% for simple and by 60% for non-NAME queries. The new function, mansearch_setup(), spends no measurable time. The pagesize chosen is optimal: * Substantially smaller pages yield no gain at all. * Larger pages provide no additional benefit and just waste memory. The chosen number of pages in the cache is a compromise: * For simple queries, a handful of pages would suffice to get the full speed effect, at an apropos(1) resident memory size of about 2.0 MB. * For non-NAME queries, a large pagecache with 2k pages (2.5 MB) might gain a few more percent in speed, but at the expense of doubling the apropos(1) resident memory size for *all* queries. * The chosen number of 256 pages (330 kB) allows nearly full speed gain for all queries at the price of a 15% resident memory size increase.
Diffstat (limited to 'mansearch.h')
-rw-r--r--mansearch.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/mansearch.h b/mansearch.h
index 706515c9..c78b00ac 100644
--- a/mansearch.h
+++ b/mansearch.h
@@ -1,4 +1,4 @@
-/* $Id: mansearch.h,v 1.12 2014/04/10 02:46:21 schwarze Exp $ */
+/* $Id: mansearch.h,v 1.13 2014/04/11 15:46:52 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -85,6 +85,7 @@ struct mansearch {
#define MANSEARCH_WHATIS 0x01 /* whatis mode: equality, no key */
};
+int mansearch_setup(int);
int mansearch(const struct mansearch *cfg, /* options */
const struct manpaths *paths, /* manpaths */
int argc, /* size of argv */