From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#49836: Support ripgrep in semantic-symref-tool-grep Date: Sun, 19 Sep 2021 00:48:24 +0300 Message-ID: References: <87sfzrbke1.fsf_-_@mail.linkov.net> <34778BC0-8D97-4266-8B1F-9D1839E858B5@acm.org> <83o88q55u2.fsf@gnu.org> <30E69411-791E-485B-AFFF-61E7965C6238@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8236"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 Cc: larsi@gnus.org, 49836@debbugs.gnu.org, juri@linkov.net To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 18 23:49:09 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRiCr-0001yV-L3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 23:49:09 +0200 Original-Received: from localhost ([::1]:47454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRiCp-0006YI-TK for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 17:49:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRiCk-0006YA-1x for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 17:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRiCj-0006Ic-Qf for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 17:49:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRiCj-0004jT-OW for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 17:49:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Sep 2021 21:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49836 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 49836-submit@debbugs.gnu.org id=B49836.163200171718162 (code B ref 49836); Sat, 18 Sep 2021 21:49:01 +0000 Original-Received: (at 49836) by debbugs.gnu.org; 18 Sep 2021 21:48:37 +0000 Original-Received: from localhost ([127.0.0.1]:37126 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRiCL-0004iq-Fg for submit@debbugs.gnu.org; Sat, 18 Sep 2021 17:48:37 -0400 Original-Received: from mail-wm1-f47.google.com ([209.85.128.47]:36729) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRiCH-0004ib-D6 for 49836@debbugs.gnu.org; Sat, 18 Sep 2021 17:48:35 -0400 Original-Received: by mail-wm1-f47.google.com with SMTP id l18-20020a05600c4f1200b002f8cf606262so12657511wmq.1 for <49836@debbugs.gnu.org>; Sat, 18 Sep 2021 14:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=78JWsHj7+NEk6LmydhE/JA5IEIS0131gIv/m3HcLQxg=; b=lUa8UzA1Fkgv+NaSYOw4cxits68OQDlApc+BPAJ74cbOlwFjG3NDBuk/I/M/RWtje3 7rh6ttA8l9J5mMCOgGH4f6/1S+rrpvVoP/OwLsnp/esfIGpZiFyuVCw4lMHRDHEVIHEx PxSJsKazw/K1HybcJx8DTC8WBNw3FNpLt+GvsnqRCoyI12gzKd/DlXro6MJgBjK4mrQl qKc0Nz0kUaKOAZRcp8INC9RM4MeOiuHwv+HXgMAFmC6CwoAkj41H/9CKd80n90+YcllH PIlOJI+OmTwtmUAVU1vOlCNdaKS6O/I4yyP6qroWlujeX+Efn4SIfLwmZHVP8sTC/cfi eHTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=78JWsHj7+NEk6LmydhE/JA5IEIS0131gIv/m3HcLQxg=; b=Gl7vR1EtgMuG7kywLRoiRqtMd761yTJm3b73lq/jlm/CBRZILHVouksyx2nvlKY0Xh 6j/0llQ2st3XQbMAqsprFqnVk1zMKEAF61Dtz2vRL48l4KNrqxvdc8e4MrRykr56cLGR SimCSBUWYXttDrU7JuhR5aIvfay6/y798nYEqR+SCTY/fMDn2c9LymgewhPVqdVJUJwm kyY0cMfcyZE6SpN2tF+guFQ61cs6zm2YDvHThv9swrHqS52pX2SoEmn2J5AMtdXu+EcS wQ6qy836ElaUBMl3mm5ovBd2iYifU02JcMZNEefaGNEmVtSZ8FGBdeCcryj/laxAjnnj 3nsQ== X-Gm-Message-State: AOAM533pIz8laen4jc+lUz68SuNGiQY+KeBmHnHmvVJKZKNmmrOY9957 okywGSsRKKVfw8QM8U38+Otpr4gJHmc= X-Google-Smtp-Source: ABdhPJyKK64blh3xnDNTh8tat+l9AlCgXo52vBXLnlCIMBhiprvb1UacagcbBYERaSy74loDgl3XGQ== X-Received: by 2002:a7b:c7c6:: with SMTP id z6mr1031929wmk.34.1632001707445; Sat, 18 Sep 2021 14:48:27 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id e2sm10917716wra.40.2021.09.18.14.48.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Sep 2021 14:48:26 -0700 (PDT) In-Reply-To: <30E69411-791E-485B-AFFF-61E7965C6238@acm.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214665 Archived-At: On 18.09.2021 17:18, Mattias EngdegÄrd wrote: > 18 sep. 2021 kl. 16.14 skrev Eli Zaretskii: > >>> If the actual command (ripgrep or something else) takes zero seconds, what if anything prevents a crisp snappy response from Emacs? >> The sub-process communications infrastructure, of course. > Yes, very likely, but also post-processing the output from the search process (matching, sorting, etc) and preparing it for display. It would be interesting to see a break-down and to see what if anything can be down to make to go faster. > Before you dig in with OS-level debugger, here are things to try to narrow down the problems: - Do the search for a common term (many matches). - Do the search for a rare term (with 1-2 matches). See how the inside/outside timings compare. I'm guessing the latter case should be snappy, with a relatively small ratio. Whatever overhead Emacs has, will probably be on the sub-process infrastructure. To investigate the former case (many matches), I suggest starting with 'benchmark-progn'. Wrapping the 'process-file' call will measure the shell invocation and getting the output into the buffer. diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index 53745b429a..7db5e79c91 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -163,8 +163,9 @@ semantic-symref-perform-search (let ((cmd (semantic-symref-grep-use-template (directory-file-name (file-local-name rootdir)) filepattern grepflags greppat))) - (process-file semantic-symref-grep-shell nil b nil - shell-command-switch cmd))) + (benchmark-progn + (process-file semantic-symref-grep-shell nil b nil + shell-command-switch cmd)))) (setq ans (semantic-symref-parse-tool-output tool b)) ;; Return the answer ans)) Measuring the subsequent semantic-symref-parse-tool-output call can also show something, but it's usually fast. Wrapping the xref--convert-hits call alone inside xref-references-in-directory should be more interesting: its work is less trivial. I don't know how much further it can be optimized, but help is welcome, of course. diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 69cabd0b5a..ab0476b2bb 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1548,9 +1548,11 @@ xref-references-in-directory (inst (semantic-symref-instantiate :searchfor symbol :searchtype 'symbol :searchscope 'subdirs - :resulttype 'line-and-text))) - (xref--convert-hits (semantic-symref-perform-search inst) - (format "\\_<%s\\_>" (regexp-quote symbol))))) + :resulttype 'line-and-text)) + (search-hits (semantic-symref-perform-search inst))) + (benchmark-progn + (xref--convert-hits search-hits + (format "\\_<%s\\_>" (regexp-quote symbol)))))) (define-obsolete-function-alias 'xref-collect-references