From: schwarze Date: Mon, 6 Jan 2014 20:53:36 +0000 (+0000) Subject: Do not sync to disk after each individual manual page (duh!), X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2f7719432ecb4287d45b03c6803cf810a9ead6e3;p=openbsd 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. --- 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 * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -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