unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
@ 2022-03-28 12:29 Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-28 12:57 ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-28 12:29 UTC (permalink / raw)
  To: 54608

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

Hi,

I attached a small patch to extend xref-search-program-alist and
xref-xref-search-program with support for ugrep[1].

Is it something that can be of any interest?

[1] https://github.com/Genivia/ugrep


In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 
1.16.0, Xaw3d scroll bars)
  of 2022-03-28 built on hathaway
Repository revision: 0e7314f6f15a20cb2ae712c09bb201f571823a6f
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04 LTS

Configured using:
  'configure --with-harfbuzz --with-native-compilation'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
   value of $LC_MONETARY: it_IT.UTF-8
   value of $LC_NUMERIC: it_IT.UTF-8
   value of $LC_TIME: it_IT.UTF-8
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=ibus
   locale-coding-system: utf-8-unix

Major mode: Shell

Minor modes in effect:
   goto-address-mode: t
   shell-dirtrack-mode: t
   pixel-scroll-precision-mode: t
   windmove-mode: t
   delete-selection-mode: t
   minibuffer-electric-default-mode: t
   savehist-mode: t
   global-so-long-mode: t
   global-subword-mode: t
   subword-mode: t
   winner-mode: t
   global-company-mode: t
   company-mode: t
   minibuffer-depth-indicate-mode: t
   vertico-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   show-paren-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   window-divider-mode: t
   column-number-mode: t
   line-number-mode: t
   transient-mark-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug dabbrev goto-addr pcmpl-args pcmpl-linux
pcmpl-unix shell pcomplete smerge-mode diff whitespace bug-reference
log-edit message sendmail yank-media rmc puny dired-x dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils
mailheader pcvs-util add-log vc-dir ewoc server misearch multi-isearch
time-date noutline outline checkdoc lisp-mnt elec-pair flymake-proc
flymake pp buffer-env vc-git diff-mode easy-mmode vc vc-dispatcher grep
compile text-property-search comint ansi-color thingatpt
vertico-directory cursor-sensor modus-operandi-theme modus-themes
pixel-scroll windmove delight comp comp-cstr warnings cl-extra help-mode
delsel minibuf-eldef savehist so-long cap-words superword subword winner
company-oddmuse company-keywords company-etags etags fileloop generator
xref project ring company-gtags company-dabbrev-code company-dabbrev
company-files company-clang company-capf company-cmake company-semantic
company-template company-bbdb company pcase mb-depth vertico ibuf-macs
rx info tex-site package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt
bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice simple cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop
case-table epa-hook jka-cmpr-hook help abbrev obarray cl-preloaded
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 295405 65421)
  (symbols 48 17422 1)
  (strings 32 62953 4379)
  (string-bytes 1 2031804)
  (vectors 16 33099)
  (vector-slots 8 928479 37143)
  (floats 8 203 609)
  (intervals 56 3658 1060)
  (buffers 992 31))

-- 
Manuel Uberti
www.manueluberti.eu

[-- Attachment #2: 0001-Support-ugrep-in-xref-search-program-alist.patch --]
[-- Type: text/x-patch, Size: 1267 bytes --]

From ff949f7c65913697bfc9f284b86c6e55479e9730 Mon Sep 17 00:00:00 2001
From: Manuel Uberti <manuel.uberti@inventati.org>
Date: Mon, 28 Mar 2022 14:26:50 +0200
Subject: [PATCH] Support ugrep in xref-search-program-alist

* lisp/progmodes/xref.el
xref-search-program-alist (Add ugrep)
xref-search-program (Add ugrep)
---
 lisp/progmodes/xref.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 5d1ba4eaf5..870dad61a4 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1715,7 +1715,8 @@ xref-search-program-alist
      .
      ;; '!*/' is there to filter out dirs (e.g. submodules).
      "xargs -0 rg <C> --null -nH --no-heading --no-messages -g '!*/' -e <R>"
-     ))
+     )
+    (ugrep . "xargs -0 ugrep <C> --null -ns -e <R>"))
   "Associative list mapping program identifiers to command templates.
 
 Program identifier should be a symbol, named after the search program.
@@ -1744,6 +1745,7 @@ xref-search-program
   :type '(choice
           (const :tag "Use Grep" grep)
           (const :tag "Use ripgrep" ripgrep)
+          (const :tag "Use ugrep" grep)
           (symbol :tag "User defined"))
   :version "28.1"
   :package-version '(xref . "1.0.4"))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
  2022-03-28 12:29 bug#54608: 29.0.50; xref-search-program-alist: support ugrep Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-28 12:57 ` Dmitry Gutov
       [not found]   ` <7134959c-0a86-c997-bab4-376bdfa901c9@inventati.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2022-03-28 12:57 UTC (permalink / raw)
  To: Manuel Uberti, 54608

Hi!

On 28.03.2022 15:29, Manuel Uberti via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> 
> I attached a small patch to extend xref-search-program-alist and
> xref-xref-search-program with support for ugrep[1].
> 
> Is it something that can be of any interest?

Sure.

Does ugrep show better performance in this use case than grep on your 
machine?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
       [not found]   ` <7134959c-0a86-c997-bab4-376bdfa901c9@inventati.org>
@ 2022-03-28 15:02     ` Dmitry Gutov
  2022-03-28 15:43       ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2022-03-28 15:02 UTC (permalink / raw)
  To: Manuel Uberti, 54608

On 28.03.2022 17:37, Manuel Uberti wrote:
> On 28/03/22 14:57, Dmitry Gutov wrote:
>> Does ugrep show better performance in this use case than grep on your 
>> machine?
> 
> With ugrep running `M-: (benchmark 100 (project-find-regexp 
> "setq-default"))` in the directory containg Emacs source code returns:
> 
> Elapsed time: 0.003903s
> 
> With regular grep I get:
> 
> Elapsed time: 0.026032s (0.022015s in 1 GCs)

0.026032s (0.022015s in 1 GCs) implies the total runtime sans GC

takes 0.026 - 0.022 = 0.004, which is pretty much the same as what you 
measured for ugrep (0.0039). The the choice of search program is 
unlikely to affect the GC time. It probably occurred randomly.

You might want to try doing a search in a larger project, for a 
relatively unique string (which has less than 100 matches, say). Then 
you can see the effect of search program's performance.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
  2022-03-28 15:02     ` Dmitry Gutov
@ 2022-03-28 15:43       ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-28 16:00         ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-28 15:43 UTC (permalink / raw)
  To: Dmitry Gutov, 54608

On 28/03/22 17:02, Dmitry Gutov wrote:
 > You might want to try doing a search in a larger project, for a relatively 
unique string (which has less than 100 matches, say). Then you can see the 
effect of search program's performance.

I tried `(benchmark-run (project-find-regexp "torvalds"))` in the Linux kernel code.

With grep: (3.628388951 6 0.3137041489999959)
With ugrep: (2.664314312 6 0.31696058299999663)

-- 
Manuel Uberti
www.manueluberti.eu





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
  2022-03-28 15:43       ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-28 16:00         ` Dmitry Gutov
  2022-03-28 16:05           ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2022-03-28 16:00 UTC (permalink / raw)
  To: Manuel Uberti, 54608

On 28.03.2022 18:43, Manuel Uberti via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> I tried `(benchmark-run (project-find-regexp "torvalds"))` in the Linux 
> kernel code.
> 
> With grep: (3.628388951 6 0.3137041489999959)
> With ugrep: (2.664314312 6 0.31696058299999663)

This is pretty good.

Did you run them a bunch of times? All subsequent searches after the 
first one are usually faster because of "warm" filesystem cache.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
  2022-03-28 16:00         ` Dmitry Gutov
@ 2022-03-28 16:05           ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-31  8:58             ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-28 16:05 UTC (permalink / raw)
  To: Dmitry Gutov, 54608

On 28/03/22 18:00, Dmitry Gutov wrote:
> This is pretty good.
> 
> Did you run them a bunch of times? All subsequent searches after the first one 
> are usually faster because of "warm" filesystem cache.

This what I get:

3 subsequent tries with grep:
(3.607880503 6 0.34762815199999864)
(3.686721065 6 0.34971310299999914)
(3.6002628420000002 6 0.33050382999999783)

3 subsequent tries with ugrep:
(2.838539952 6 0.33570421699999997)
(3.002044363 6 0.3332255390000043)
(2.750283601 6 0.33057494999999903)

-- 
Manuel Uberti
www.manueluberti.eu





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
  2022-03-28 16:05           ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-31  8:58             ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-04-02  1:35               ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-31  8:58 UTC (permalink / raw)
  To: Dmitry Gutov, 54608

Hi Dmitry,

is there something more you need me to do on this?


Thanks

-- 
Manuel Uberti
www.manueluberti.eu





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
  2022-03-31  8:58             ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-04-02  1:35               ` Dmitry Gutov
  2022-04-02  6:53                 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2022-04-02  1:35 UTC (permalink / raw)
  To: Manuel Uberti, 54608-done

Hi Manuel,

On 31.03.2022 11:58, Manuel Uberti via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> Hi Dmitry,
> 
> is there something more you need me to do on this?

Both code and testing look good, thanks.

I've pushed the change in 9468ab2570.

Please take a look at the commit message, though. It would be helpful if 
your patches use the required format right away.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#54608: 29.0.50; xref-search-program-alist: support ugrep
  2022-04-02  1:35               ` Dmitry Gutov
@ 2022-04-02  6:53                 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 9+ messages in thread
From: Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-04-02  6:53 UTC (permalink / raw)
  To: Dmitry Gutov, 54608-done

On 02/04/22 03:35, Dmitry Gutov wrote:
> Both code and testing look good, thanks.
> 
> I've pushed the change in 9468ab2570.

Thanks, and sorry about the typo that you had to fix.

> Please take a look at the commit message, though. It would be helpful if your 
> patches use the required format right away.

Thanks for the tip, I will do. I thought I had done it this time but I see now 
that I missed something.

-- 
Manuel Uberti
www.manueluberti.eu





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-04-02  6:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 12:29 bug#54608: 29.0.50; xref-search-program-alist: support ugrep Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-28 12:57 ` Dmitry Gutov
     [not found]   ` <7134959c-0a86-c997-bab4-376bdfa901c9@inventati.org>
2022-03-28 15:02     ` Dmitry Gutov
2022-03-28 15:43       ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-28 16:00         ` Dmitry Gutov
2022-03-28 16:05           ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-31  8:58             ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-02  1:35               ` Dmitry Gutov
2022-04-02  6:53                 ` Manuel Uberti via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).