From 8af38b3d67df7e658bfc44cdd727c45ceb20191a Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 6 Jan 2014 20:53:40 +0000 Subject: 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. --- mandocdb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'mandocdb.c') 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 * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -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 -- cgit v1.2.3-56-ge451