aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-01-06 20:53:40 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-01-06 20:53:40 +0000
commit8af38b3d67df7e658bfc44cdd727c45ceb20191a (patch)
tree70bc67e3dcac6c4fc448f47b8d542a532af5cc5a /mandocdb.c
parent89f86436d75b5a251d1132d30feb5a07cd39cbce (diff)
downloadmandoc-8af38b3d67df7e658bfc44cdd727c45ceb20191a.tar.gz
mandoc-8af38b3d67df7e658bfc44cdd727c45ceb20191a.tar.zst
mandoc-8af38b3d67df7e658bfc44cdd727c45ceb20191a.zip
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 'mandocdb.c')
-rw-r--r--mandocdb.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 2fd918c1..90351637 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.106 2014/01/06 15:32:47 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.107 2014/01/06 20:53:40 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -969,6 +969,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);
@@ -1059,6 +1062,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
@@ -1754,8 +1760,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]);
@@ -1787,8 +1791,6 @@ dbadd(const struct mpage *mpage, struct mchars *mc)
free(key->rendered);
free(key);
}
-
- SQL_EXEC("END TRANSACTION");
}
static void