unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
To: "Antoine Beaupré" <anarcat@orangeseeds.org>, notmuch@notmuchmail.org
Subject: Re: compacting the notmuch database through systemd
Date: Wed, 04 Dec 2019 13:09:03 -0500	[thread overview]
Message-ID: <871rtk6k00.fsf@fifthhorseman.net> (raw)
In-Reply-To: <87v9qz93b0.fsf@curie.anarc.at>

[-- Attachment #1: Type: text/plain, Size: 3651 bytes --]

Thanks for raising this, Anarcat!

One more advantage that i think you haven't noted yet about regular
database compaction:

"notmuch compact" tends to get rid of a lot of lingering written data
that is no longer referenced.  While this isn't robust "secure
deletion", it's a lot better than not compacting.  see
https://trac.xapian.org/ticket/742 for more discussion.

Some questions below…

On Sun 2019-12-01 15:52:19 -0500, Antoine Beaupré wrote:

> Thanks to Bremner, I just realized that notmuch-compact(1) is a thing,
> and that thing allows me to compress my notmuch databases by about 50%.

do you know why you get the large size/speed gain?  do you regularly
delete files from your message archive?

> So I whipped together two systemd units (attached) that will run that
> command every month on my notmuch database. Just drop them in
> `~/.config/systemd/user/` and run:
>
>     systemctl --user daemon-reload
>     systemctl --user enable notmuch-compact.timer
>     systemctl --user start notmuch-compact.timer

("systemctl --user enable --now notmuch-compact.timer" will suffice for
the final two commands on any reasonably modern version of systemd)

How long does it take for these the notmuch-compact.service to complete?

What happens if this is happening when, say, you put your machine to
sleep, or you power it down?

While notmuch-compact.service is running, does "notmuch new" or "notmuch
insert" work?  If not, how do they fail (e.g. blocking indefinitely,
returning a comprehensible error message)?

Can you read your mail while notmuch-compact.service is running?

> Maybe those could be shipped with the Debian package somehow? Not sure
> how that works, but I think that's how gpg-agent gets started now, if
> you want any inspiration...

gpg-agent is socket-activated, which is different from the
timer-activation you are proposing here.

We could easily ship these systemd user unit files in the notmuch
package now that #764678 is resolved.  Do you think that the timer
should be enabled by default?

What should happen if the user hasn't set up notmuch?  Maybe we need a
ConditionPathExists= or something like that on either the .timer or the
.service?

Do we expect this to run even when the user isn't logged in at all (a
background compaction?)

it always gets more complex when you think about trying to do it at
scale :)

> It would be great if notmuch-new ran this on its own, when it
> thought that this was "important", somehow like git-gc sometimes runs on
> its own.

I'm not convinced i like this idea without more profiling and an
understanding of what it might cause.  I have grown to *really* dislike
the highly variable latency and warnings caused by GnuPG's
"auto-check-trustdb", for example (especially as the keyring grows
larger).

>  [ notmuch-compact.timer: text/plain ]
>  [Unit]
>  Description=compact the notmuch database

systemd timer unit descriptions typically include some mention of the
duration.  See for example:

/lib/systemd/system/systemd-tmpfiles-clean.timer
"Daily Cleanup of Temporary Directories"

/lib/systemd/system/certbot.timer
"Run certbot twice daily"

/lib/systemd/system/phpsessionclean.timer
"Clean PHP session files every 30 mins"

I recommend:

    Description=Compact the notmuch database every month

> [ notmuch-compact.service: text/plain ]
> [Unit]
> Description=compact the notmuch database

The convention is to lead with an upper-case letter:

    Description=Compact the notmuch database

OK OK enough with the nit-picking!

Happy hacking,

    --dkg

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

  parent reply	other threads:[~2019-12-04 18:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-01 20:52 compacting the notmuch database through systemd Antoine Beaupré
2019-12-02 13:29 ` Antoine Beaupré
2019-12-04 18:09 ` Daniel Kahn Gillmor [this message]
2019-12-04 19:51   ` Antoine Beaupré
2019-12-05 11:29     ` Jorge P. de Morais Neto
2019-12-05 11:38       ` Georg Faerber
2019-12-06 19:41         ` Daniel Kahn Gillmor
2019-12-08 14:38           ` Jorge P. de Morais Neto
2019-12-08 15:15             ` Chris Coutinho
2019-12-08 16:56             ` David Bremner
2019-12-12 22:44               ` Tomi Ollila
2019-12-05 17:02       ` Antoine Beaupré

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871rtk6k00.fsf@fifthhorseman.net \
    --to=dkg@fifthhorseman.net \
    --cc=anarcat@orangeseeds.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).