diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-01-06 20:53:40 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-01-06 20:53:40 +0000 |
commit | 9c540f5100e97dab38afdf4a27540ed63060348b (patch) | |
tree | 4eac5bce6f94ae5c0ac7dbdc88940e0fef285408 /mandocdb.c | |
parent | 64929c4dd7ee9b3c9e2f16421b938ea9ffc8696c (diff) | |
download | mandoc-9c540f5100e97dab38afdf4a27540ed63060348b.tar.gz |
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.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 |