diff options
author | 2014-01-06 20:53:36 +0000 | |
---|---|---|
committer | 2014-01-06 20:53:36 +0000 | |
commit | 2f7719432ecb4287d45b03c6803cf810a9ead6e3 (patch) | |
tree | 949e33b60d820db6dc733a9d0ab740f82d15393d /usr.bin/mandoc/mandocdb.c | |
parent | sync (diff) | |
download | wireguard-openbsd-2f7719432ecb4287d45b03c6803cf810a9ead6e3.tar.xz wireguard-openbsd-2f7719432ecb4287d45b03c6803cf810a9ead6e3.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 'usr.bin/mandoc/mandocdb.c')
-rw-r--r-- | usr.bin/mandoc/mandocdb.c | 12 |
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 |