From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el Date: Sun, 07 Mar 2021 21:16:18 +0100 Message-ID: References: <87im69uzlt.fsf@mail.linkov.net> <25782781-4baa-5d44-99a1-2e57552ab3a0@yandex.ru> <666564dc-0252-6bf5-04e1-58c9916cffbe@yandex.ru> <92f18de5-6dae-8041-2da0-e4b782f9003e@yandex.ru> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28960"; mail-complaints-to="usenet@ciao.gmane.io" To: Dmitry Gutov , juri@linkov.net, 46859@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 07 21:17:15 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 1lIzpy-0007Q7-7V for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Mar 2021 21:17:14 +0100 Original-Received: from localhost ([::1]:44456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIzpx-0002P5-91 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Mar 2021 15:17:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIzpn-0002LX-96 for bug-gnu-emacs@gnu.org; Sun, 07 Mar 2021 15:17:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lIzpm-0004JU-Hq for bug-gnu-emacs@gnu.org; Sun, 07 Mar 2021 15:17:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lIzpm-0007fB-Ea for bug-gnu-emacs@gnu.org; Sun, 07 Mar 2021 15:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Mar 2021 20:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46859 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46859-submit@debbugs.gnu.org id=B46859.161514818429391 (code B ref 46859); Sun, 07 Mar 2021 20:17:02 +0000 Original-Received: (at 46859) by debbugs.gnu.org; 7 Mar 2021 20:16:24 +0000 Original-Received: from localhost ([127.0.0.1]:41575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lIzpA-0007dz-BZ for submit@debbugs.gnu.org; Sun, 07 Mar 2021 15:16:24 -0500 Original-Received: from out1.migadu.com ([91.121.223.63]:26078) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lIzp7-0007dl-AZ for 46859@debbugs.gnu.org; Sun, 07 Mar 2021 15:16:23 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1615148179; 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=okQnYE3jwCSp11O9vhcyI4egdBQmvoojg7nMnJnDYts=; b=SL6Ec+oBsPQ9t7gOPllI8+AkyrZUeHeBfdZ65the8+BADl+Y7jHzah+cXwiPpURSZNbm0Y bdSTGFHjlW7ZP/n1tIBKGF0qvnhiEcpVMzjrTP0azDQVqYJ058tFg0sHGv0gVWT7ivoiQv oiMv9MgMgBgLG+ki4sI1FO7QG/ZiKfIcXC4dq1MJsVZjOjwdTOoShLWY3Rg3MmlN3S6rHB jJUrt8uIZ0NCC/5ZsWqQrsobI+JeftsSEuZlidVWzPVfxxkZiksh/LyQr9L94MSIHIx6AR H2rZz+GmzswKEjqnX3pd29Rv4oU7XYLBTzp9P1stc2O87dVJ0nUkm9v5GWWVaw== In-Reply-To: <92f18de5-6dae-8041-2da0-e4b782f9003e@yandex.ru> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: theo@thornhill.no 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:201774 Archived-At: Hi Dmitry, > I just got around to testing this properly (sorry), No worries > and so far I've been > able to reproduce the slow behavior only when there are many matches in > the "big long line" file. I'm using a 500KB minified CSS as an example. > > When there are only a few matches, the search is relatively > instantaneous. So that's a weird mismatch with your reports. If you have > some details to add to reproduce the slowdown in the "few matches" case, > that could be helpful too. Hmm. Theres always a possibility of a human error on my part during the benchmarks, of course! > > I'm currently looking at the patch and trying to figure out whether we > could apply some smaller change, or a change not in xref--insert-xrefs > (which is relatively complex already) with the same benefits. > Yeah, I also wanted to not add too much to that function, but I couldn't get improvements other places :) > Also: > > - Could you explain the change to xref--collect-matches-1 in the most > recent patch? In my testing it doesn't move the needle at all, and it > seems unnecessary because neither Grep or Ripgrep report matches on the > same line separately with the current arguments that we pass to them. > But if we did... what's the idea? Skip all subsequent matches, no matter > if they're far or close? > Yeah, skipping subsequent matches yielded an improvement from ~1.09 to ~1.03 seconds, so not the biggest improvement, but it was consistent. Thus I kept it. > - What do you think about making an effort to actually retain all the > matches in the output? I see why we would want to do that, but as I mentioned in the last mail I sent, these files are mostly "junk" anyways. However, it is probably best to be able to retain them if we can. I just think speed should be more important > That would mean interpreting the xref-truncate-line-to value (or > however the var could be renamed) as the maximum number of chars to > render on the line *per match*. And if there is too much text between > them, those parts can become "(truncated...)". Your current > implementation can cut off valid matches, and we probably want to > preserve them if feasible. OTOH, the default value could go down to > 200 with this approach. > Yeah, I had an implementation where I "snipped" between matches and concatenated them together, but that still yielded too large a line for my emacs on a 3 million char length file, so I scrapped that idea. I guess it still is possible, though! > What I mean is, we can provide the "fullest featured" default behavior, > one which never omits any valid matches and just truncated the line > context around them, and the users who want even faster searches (at the > cost of missing matches, esp. in find-replace scenarios) have something > else to customize too. Yeah, I think this is the best approach too. Especially for grep users. I'll still probably use (add-to-list 'xref-search-program-alist '(ripgrep . "xargs -0 rg -nH --no-messages -g '!*/' -e -M 400 --max-columns-preview | sort -t: -k1,1 -k2n,2")) Or something to that effect anyways :) -- Theo