From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#59787: 29.0.60; Very slow pos-visible-in-window-p with long truncated lines Date: Wed, 07 Dec 2022 16:25:22 +0200 Message-ID: <83o7sf47fx.fsf@gnu.org> References: <83v8mteffc.fsf@gnu.org> <86bkofvd0v.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33152"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59787@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 07 15:26:31 2022 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 1p2vNW-0008Nl-RS for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Dec 2022 15:26:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2vNC-0003mO-1R; Wed, 07 Dec 2022 09:26:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2vN9-0003mA-Gu for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 09:26:08 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2vN4-0002Vf-ES for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 09:26:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2vN4-0001Q1-3G for bug-gnu-emacs@gnu.org; Wed, 07 Dec 2022 09:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Dec 2022 14:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59787 X-GNU-PR-Package: emacs Original-Received: via spool by 59787-submit@debbugs.gnu.org id=B59787.16704231475447 (code B ref 59787); Wed, 07 Dec 2022 14:26:02 +0000 Original-Received: (at 59787) by debbugs.gnu.org; 7 Dec 2022 14:25:47 +0000 Original-Received: from localhost ([127.0.0.1]:50494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2vMo-0001Pn-SJ for submit@debbugs.gnu.org; Wed, 07 Dec 2022 09:25:47 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2vMk-0001Ph-JI for 59787@debbugs.gnu.org; Wed, 07 Dec 2022 09:25:45 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2vMf-0001rb-2o; Wed, 07 Dec 2022 09:25:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=nU6ETS0qXyvSKadXC16MUjsYfALKnApodIRHSL5JdU4=; b=hyNJXOCipTa4 pQTOyDlCk/c+LbQLNJVJycSFy7YmN09bMYsQM5sZAB85WQxkywDDqJe9WjMjaP2K5GF4kXlsiAddm gWTBFtxBo4JWdk3w9kdIkyajc3a2ZtN/ol38Dt9yqP+GdUq4UnT2dMqIkgAJm3zJdGcsRU60Qvq7o GjMzMA14XRJ3eKxzuId62B5WwR6Gj+JwIIywJMOTRR1nYOK9nNfuZ5f/rxs9Y45AuwMPD04nlWhXr qQEGiJRwezH7bPAwLDlgcBt7DfEIhCPhB9un7wRUf3yAFod6Lpq7onLGxhhJOAAY31CPR/cUFhUZz /EVyY4vP4J1AXVOT7SKRug==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2vMb-0001hC-83; Wed, 07 Dec 2022 09:25:36 -0500 In-Reply-To: <86bkofvd0v.fsf@mail.linkov.net> (message from Juri Linkov on Wed, 07 Dec 2022 09:58:40 +0200) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250192 Archived-At: > From: Juri Linkov > Cc: 59787@debbugs.gnu.org > Date: Wed, 07 Dec 2022 09:58:40 +0200 > > > As reported in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56682#1977: > > > > 2. after starting Isearch at a large column number, > > Emacs hangs up indefinitely, e.g. with > > 'M-g TAB 10000000 RET C-s' then even C-g doesn't get out. > > Debugging shows that the problem is in 'isearch-update' > > where the call to 'pos-visible-in-window-group-p' doesn't return. > > When this call is removed, the search is instantaneous. > > (Optimizing lazy-highlight is a separate problem in bug#56815.) > > > > The problem is that pos-visible-in-window-p starts from window-start point > > and goes to the POSITION passed as argument using move_it_to, which in this > > case is very slow, because it has all the 10000000 columns to traverse. > > > > The solution is to introduce shortcuts into pos_visible_p in this case. > > Could you explain why pos-visible-in-window-p is instantaneous at any > position when long lines are not truncated. Why it doesn't need to > traverse 10000000 columns in this case? Because when lines are wrapped, window-start is at the first visible character in the window, which is much closer to point than 10000000 characters, even with today's huge screens. And pos-visible-in-window-p starts from window-start position, because that's where it _knows_ the exact X coordinate. (It needs the X coordinate to start from so that it could report the X coordinate of point when the 3rd argument is non-nil.) By contrast, when lines are truncated and the window is hscrolled, window-start is at the first character of the first line, which in the above case is 10000000 characters before the first visible character. So starting from window-start will need to traverse 10000000 invisible characters before it gets to point. (Which if you think about it, almost suggests the shortcut for when the lines are very long...)