]> git.cworth.org Git - notmuch-wiki/blob - performance.mdwn
News for release 0.38.3
[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 compact it. 
78 This can be easily achieved with `notmuch compact`:
79
80     $ notmuch compact
81
82 Note that this process can take a long time for large database and a write lock
83 will be held for the duration to ensure data integrity. The process will create
84 a new compacted database in a temporary directory and finally replace the
85 original database if compaction is successful. For added safety you can provide
86 `--backup=<directory>` option to preserve a copy of the original database. For
87 more details on this process see `notmuch-compact` man page.
88
89 ### More information about this in the email archives:
90
91 * [Carl Worth](https://notmuchmail.org/pipermail/notmuch/2010/001105.html)
92
93 * [Sebastian Spaeth](https://notmuchmail.org/pipermail/notmuch/2011/004048.html)
94
95 * [Pieter Praet](https://notmuchmail.org/pipermail/notmuch/2011/004175.html)