summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-01-06 20:53:37 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-01-06 20:53:37 +0000
commited88b4cf885350db88c78aed6a0c969b999eb72a (patch)
tree0af8b9baa86a0930575251aafc055e1ac34c5328 /usr.bin/mandoc/mandocdb.c
parentef563b7caed8d63baae25fd7cfd00f98e8573b18 (diff)
Do not sync to disk after each individual manual page (duh!),
only sync to disk one single time when all data is ready. Rebuild times for /usr/share/man/mandoc.db shrink on my notebook: In standard mode from 45 seconds to 11 seconds (75% reduction) In -Q mode from 25 seconds to 3.1 seconds (87% reduction) For comparison: makewhatis(8): 4.2 seconds That is, in -Q mode, we are now *faster* than the existing makewhatis(8), and careful profiling shows there is still a lot of room for improval.
Diffstat (limited to 'usr.bin/mandoc/mandocdb.c')
-rw-r--r--usr.bin/mandoc/mandocdb.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index a77cfef7fd0..4db117d7f23 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.63 2014/01/06 15:32:44 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.64 2014/01/06 20:53:36 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -961,6 +961,9 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
str_info.hfree = hash_free;
str_info.key_offset = offsetof(struct str, key);
+ if (0 == nodb)
+ SQL_EXEC("BEGIN TRANSACTION");
+
mpage = ohash_first(&mpages, &pslot);
while (NULL != mpage) {
mlinks_undupe(mpage);
@@ -1051,6 +1054,9 @@ mpages_merge(struct mchars *mc, struct mparse *mp)
ohash_delete(&strings);
mpage = ohash_next(&mpages, &pslot);
}
+
+ if (0 == nodb)
+ SQL_EXEC("END TRANSACTION");
}
static void
@@ -1746,8 +1752,6 @@ dbadd(const struct mpage *mpage, struct mchars *mc)
if (nodb)
return;
- SQL_EXEC("BEGIN TRANSACTION");
-
i = 1;
SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form);
SQL_STEP(stmts[STMT_INSERT_PAGE]);
@@ -1779,8 +1783,6 @@ dbadd(const struct mpage *mpage, struct mchars *mc)
free(key->rendered);
free(key);
}
-
- SQL_EXEC("END TRANSACTION");
}
static void