From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id eEC8CDsQ02KPXgAAbAwnHQ (envelope-from ) for ; Sat, 16 Jul 2022 21:23:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cDTaCDsQ02K08gAA9RJhRA (envelope-from ) for ; Sat, 16 Jul 2022 21:23:39 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 883C128D49 for ; Sat, 16 Jul 2022 21:23:38 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 040F55E53F; Sat, 16 Jul 2022 19:23:36 +0000 (UTC) Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) by mail.notmuchmail.org (Postfix) with ESMTPS id 639E15E01E for ; Sat, 16 Jul 2022 19:23:33 +0000 (UTC) Received: from c53 (gw1.nor.fi [185.218.193.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: too) by meesny.iki.fi (Postfix) with ESMTPSA id A37FE20167; Sat, 16 Jul 2022 22:23:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1657999411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t3W2JOidLrlT82W0UgqcwxAWIl1IlJzlwSc77+kVglE=; b=jc2tuvUIyDKtqWr1pg6XCaHgN95Kylz9Ro9nBWNFry9eUAjpgb5EpqnG3ZeGRvJcbyj0tr fQy07lSRv31axnETIKvwJRT57IEoHH3nypV1AxBEWJxZIRewDyriXchlpf8HA5gFOveS+q 1cv2t5peoOIBlnPIRiZZ+HZE2XAz/8g= From: Tomi Ollila To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH v2] CLI/git: opportunistically use bindings to check for known messages In-Reply-To: <20220715144301.793133-1-david@tethera.net> References: <20220703151103.1800726-5-david@tethera.net> <20220715144301.793133-1-david@tethera.net> User-Agent: Notmuch/0.36+55~gfb9633d (https://notmuchmail.org) Emacs/27.1 X-Face: HhBM'cA~ MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1657999411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t3W2JOidLrlT82W0UgqcwxAWIl1IlJzlwSc77+kVglE=; b=ao6V6jid3z/w4HrtFN5Z4xAMHz80xmnMR/DFFFe3DtDfXDx57AmC/ZDCideaNpLhMlX+oh TyAdCpzMgky1tn/a4LcXzA06gQaYgQTUJG10O/+1CAN7goyAMSy/dBdpEfgTArOZqLUDd0 0yrd70SvXJMngoizNmZb3U5ivmfBXBo= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1657999411; a=rsa-sha256; cv=none; b=AUY41YnQ2xC0NJqUpPy/xdWp5JrCffU+NR6cx3fBvKY5fZEJJq4JuKNSQ6UDVELlKIs1Jq aB4k/KExW2UpCNarDOVaWt+ZIQLtV7NlNCgc5j+biJrEcB1YhFAaNoKP0m9htNRbTw3ZtW qR8vgYN0yshAmMh9RP8CJULoKFnYwvQ= Message-ID-Hash: LHEZ6NGTNAZXNWMUIWXOPHYLWSWMX4CF X-Message-ID-Hash: LHEZ6NGTNAZXNWMUIWXOPHYLWSWMX4CF X-MailFrom: tomi.ollila@iki.fi X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1657999419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=QT9jMyhJ5MYfwwM9vCYCeUupyTby2u2JmHtX9aHIbB0=; b=rJGkbsaWRw0+PQAg1sX576i8QW0P0NZvHmcWtcKoWAaAnwx1HC0jB83IUXIVKG1tVbEnCf fb84grDCFvtHhsjiNEKTnPmzmk2502GMCTnLa5e3a52dJ/vy1h1n6GXmaw9H8yPY5l8RhU 1f34d5OltMt4QUQIWaL/MQDRttzN1Do4XVIuQVLxTzpnzignuS8gF6jA4RTvs6DgDRwpVx T5hHipowiCay1uePfUKlmA5d+PpUG9wSXj8TEpge7mOKx6jY0gP4ntQ/l1cXSPE9QWeAv7 pNHfmmlAVnh932ahIXl0or88SIoRwdXjII6hS7+1185fvTG4r3s8AbKRht3Bjg== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1657999419; a=rsa-sha256; cv=fail; b=gcoET6KSB0ChK72jXlkm2PRE59cRkv2AHX+hNFa+hhMGMJnlSl1N/qg0ToxbUKZtpWOb8e dnjgDrvfWd2ULZrUKrWVlj7mAwFwjXlowbZ82K4niQVPfaDjIbcUJGtLDyPLTeCKYWzCes BDG3kLgNqsI8jHEu8HhSRmL8vrqzrD9aZDAUduDxyaOzCBdOy/ZeZmNSV7yf1epFWIx0Os DI0QxF48R0Le0199B84kwpv1ejrZRpdY+97sWUx6YwI7ORvzLOg2NayRLD7pO5AxqPK0Mn wLS2M1QxFrRTSIdSP72Dyzgi915k10wdz9hf7+P51YHFx9KHk2Ey5URe7rq4lQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=meesny header.b=jc2tuvUI; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 2.25 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=meesny header.b=jc2tuvUI; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 883C128D49 X-Spam-Score: 2.25 X-Migadu-Scanner: scn0.migadu.com X-TUID: PkyC6xiwGqL+ On Fri, Jul 15 2022, David Bremner wrote: > If the bindings are installed, use them to avoid one exec of notmuch > search per message. tnx. continues to work for me where I have symlink to nmbug in ~/bin/. some time in the future i'll investigate whether i get python3 path/to/nmbug.zip ... working but not today... the series looks good to me. Tomi > --- > notmuch-git.py | 33 ++++++++++++++++++++++++++++----- > 1 file changed, 28 insertions(+), 5 deletions(-) > > I decided to leave the old (slow) path in for now, since it is fast > enough for use of nmbug to manage notmuch developement tags. > > > diff --git a/notmuch-git.py b/notmuch-git.py > index 4d9887c8..ceb86fbc 100644 > --- a/notmuch-git.py > +++ b/notmuch-git.py > @@ -698,6 +698,32 @@ def _is_unmerged(ref='@{upstream}'): > stdout=_subprocess.PIPE, wait=True) > return base != fetch_head > > +class DatabaseCache: > + def __init__(self): > + try: > + from notmuch2 import Database > + self._notmuch = Database() > + except ImportError: > + self._notmuch = None > + self._known = {} > + > + def known(self,id): > + if id in self._known: > + return self._known[id]; > + > + if self._notmuch: > + try: > + _ = self._notmuch.find(id) > + self._known[id] = True > + except LookupError: > + self._known[id] = False > + else: > + (_, stdout, stderr) = _spawn( > + args=['notmuch', 'search', '--output=files', 'id:{0}'.format(id)], > + stdout=_subprocess.PIPE, > + wait=True) > + self._known[id] = stdout != None > + return self._known[id] > > @timed > def get_status(): > @@ -705,14 +731,11 @@ def get_status(): > 'deleted': {}, > 'missing': {}, > } > + db = DatabaseCache() > 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: > + if db.known(id): > status['deleted'][id] = tags > else: > status['missing'][id] = tags > -- > 2.35.1 > > _______________________________________________ > notmuch mailing list -- notmuch@notmuchmail.org > To unsubscribe send an email to notmuch-leave@notmuchmail.org