]> git.cworth.org Git - notmuch-wiki/blob - performance.mdwn
performance.mdwn: update on xapian database format
[notmuch-wiki] / performance.mdwn
1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Optimize notmuch's performance
3
4 [[!toc levels=2]]
5
6 ## Use of ecryptfs slows notmuch down.
7
8 I noticed that my `notmuch new` was really slow (several minutes) for
9 less then 20 new emails (around 20K in my database).
10
11 The performance tests in the notmuch source didn't show any real
12 issue, even on a non-encrypted ext4 fs.
13
14 After investigation and running different tests, a switch to a
15 LUKS-btrfs based filesystem to replace the ext4-ecryptfs resolved the
16 issue. It now takes some seconds to index hundreds of messages.
17
18 ## Xapian database format: chert vs. flint vs. glass
19
20 Depending on the Xapian version that was used during the initial notmuch
21 database creation, you might use another database format than the most recent
22 one, which is often faster.
23
24 Check whether you are on chert, flint or glass:
25
26     $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
27     iamglass
28
29 If it does not say `iamglass`, but `iamchert` or `iamflint`, than you should
30 migrate (read on).
31
32 There might be a file named `flintlock`, it is no indicator for your database
33 format, but also used in case of `chert`.
34
35 ### Migrate from an older format to the most recent one (glass)
36
37 Make sure you are using xapian 1.4.x (depends on your distribution)
38
39 XXX: add examples for different distributions
40
41 Backup your notmuch tags:
42
43     $ cd
44     $ notmuch dump --output=notmuch-dump-oldformat
45
46 Move away your old database:
47
48     $ mv $(notmuch config get database.path)/.notmuch/ notmuch-db.bak
49
50 Find and import your messages, a new and fresh database will be
51 created:
52
53     $ notmuch new
54
55 Restore your tags:
56
57     $ notmuch restore --input=notmuch-dump-oldformat
58
59 Check whether you are on glass now:
60
61     $ ls $(notmuch config get database.path)/.notmuch/xapian/iam*
62     iamglass
63
64   If it says `iamflint` or `iamchert`, most likely you are still using an old
65   xapian version.
66
67 Clean-up: if you are sure everything is fine, you can delete the old
68 things. The dump of your tags you might want to keep anyway as a
69 backup - on the other hand you should have some mechanism in place to
70 make regular backups of your notmuch database:
71
72     $ rm notmuch-dump-oldformat
73     $ rm -R notmuch-db.bak
74
75 ### Compact your database
76
77 In order to greatly reduce the size of your database, you should
78 compact it. Carl says "This functionality is not yet available in the
79 Xapian library interface or else I would probably make notmuch call it
80 after building the database." and Pieter "[compacting] will cause
81 writes to be a bit more expensive in the short term, but will
82 significantly reduce the db's size, which your SSD will surely
83 appreciate."
84
85 This needs xapian 1.2
86
87 Backup your database:
88
89     $ cd
90     $ notmuch dump --output=notmuch-dump-b4compact
91
92 Compact it:
93
94     $ cd $(notmuch config get database.path)/.notmuch
95     $ xapian-compact --no-renumber xapian xapian-compacted
96
97 Remove old and renamed compacted, if compacting went well:
98
99     $ rm -R xapian
100     $ mv xapian-compacted xapian
101
102
103 ### More information about this in the email archives:
104
105 * [Carl Worth](https://notmuchmail.org/pipermail/notmuch/2010/001105.html)
106
107 * [Sebastian Spaeth](https://notmuchmail.org/pipermail/notmuch/2011/004048.html)
108
109 * [Pieter Praet](https://notmuchmail.org/pipermail/notmuch/2011/004175.html)