From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 4/4] CLI/git: replace calls to notmuch-search with database access
Date: Sun, 3 Jul 2022 12:11:03 -0300 [thread overview]
Message-ID: <20220703151103.1800726-5-david@tethera.net> (raw)
In-Reply-To: <20220703151103.1800726-1-david@tethera.net>
This introduces a dependency on the (new) python bindings, but since
it also yields a 4x performance improvement on the large performance
corpus, I think it is worth it.
---
debian/control | 1 +
notmuch-git.py | 18 +++++++++---------
test/T850-git.sh | 2 ++
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/debian/control b/debian/control
index 0ffe958c..7099fe97 100644
--- a/debian/control
+++ b/debian/control
@@ -73,6 +73,7 @@ Depends:
git,
notmuch,
python3,
+ python3-notmuch2
${misc:Depends}
Description: thread-based email index, search and tagging
Notmuch is a system for indexing, searching, reading, and tagging
diff --git a/notmuch-git.py b/notmuch-git.py
index a3ae15f7..eac24a46 100644
--- a/notmuch-git.py
+++ b/notmuch-git.py
@@ -701,21 +701,21 @@ def _is_unmerged(ref='@{upstream}'):
@timed
def get_status():
+ from notmuch2 import Database
+
status = {
'deleted': {},
'missing': {},
}
with PrivateIndex(repo=NOTMUCH_GIT_DIR, prefix=TAG_PREFIX) as index:
maybe_deleted = index.diff(filter='D')
- for id, tags in maybe_deleted.items():
- (_, stdout, stderr) = _spawn(
- args=['notmuch', 'search', '--output=files', 'id:{0}'.format(id)],
- stdout=_subprocess.PIPE,
- wait=True)
- if stdout:
- status['deleted'][id] = tags
- else:
- status['missing'][id] = tags
+ with Database() as notmuch:
+ for id, tags in maybe_deleted.items():
+ try:
+ _ = notmuch.find(id)
+ status['deleted'][id] = tags
+ except LookupError:
+ status['missing'][id] = tags
status['added'] = index.diff(filter='A')
return status
diff --git a/test/T850-git.sh b/test/T850-git.sh
index 81400328..b1bc9e7e 100755
--- a/test/T850-git.sh
+++ b/test/T850-git.sh
@@ -7,6 +7,8 @@ if [ $NOTMUCH_HAVE_SFSEXP -ne 1 ]; then
test_done
fi
+export PYTHONPATH="$NOTMUCH_BUILDDIR/bindings/python-cffi/build/stage:${PYTHONPATH:+:$PYTHONPATH}"
+
# be very careful using backup_database / restore_database in this
# file, as they fool the cache invalidation checks in notmuch-git.
--
2.35.2
next prev parent reply other threads:[~2022-07-03 15:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-03 15:10 performance improvements for notmuch git checkout David Bremner
2022-07-03 15:11 ` [PATCH 1/4] debian: add git as a build-dependency, for the test suite David Bremner
2022-07-07 10:30 ` David Bremner
2022-07-03 15:11 ` [PATCH 2/4] perf-test: add tests for notmuch-git David Bremner
2022-07-05 16:40 ` Tomi Ollila
2022-07-07 9:47 ` David Bremner
2022-07-03 15:11 ` [PATCH 3/4] CLI/git: current cache contents (file list) of index David Bremner
2022-07-03 15:11 ` David Bremner [this message]
2022-07-07 14:51 ` [PATCH 4/4] CLI/git: replace calls to notmuch-search with database access Tomi Ollila
2022-07-07 15:59 ` David Bremner
2022-07-09 19:35 ` Michael J Gruber
2022-07-15 14:43 ` [PATCH v2] CLI/git: opportunistically use bindings to check for known messages David Bremner
2022-07-16 19:23 ` Tomi Ollila
2022-07-17 0:51 ` David Bremner
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=20220703151103.1800726-5-david@tethera.net \
--to=david@tethera.net \
--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).