unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH 4/4] CLI/git: replace calls to notmuch-search with database access
Date: Thu, 07 Jul 2022 17:51:59 +0300	[thread overview]
Message-ID: <y3fmy5u.bs9wcj-too@iki.fi> (raw)
In-Reply-To: <20220703151103.1800726-5-david@tethera.net>

On Sun, Jul 03 2022, David Bremner wrote:

> 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)

One extra space above.

For me looking further here stalled to the introduced python bindings
dependency -- it make is much harder to make working notmuch-git
installation...

... currently it is enough that notmuch(1) binary is in PATH -- I
personally just build new versions of notmuch and copy it to $HOME/bin
and it just works(tm). Same with nmbug. To get python bindings work one has
to be able to build the c module, and then copy the set of python files (or
make zip archive) to a directory (along w/ that c module -- where did that
get copied cannot remember now...:)

I've trying to think if there were a way to somehow run only one notmuch
command instead of notmuch search on all maeby-deleted files -- or
alternatively attempt to load python bindings and in case of failure use
the notmuch-search methid...

Tomi

> +                    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
>
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org

  reply	other threads:[~2022-07-07 14:52 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 ` [PATCH 4/4] CLI/git: replace calls to notmuch-search with database access David Bremner
2022-07-07 14:51   ` Tomi Ollila [this message]
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=y3fmy5u.bs9wcj-too@iki.fi \
    --to=tomi.ollila@iki.fi \
    --cc=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).