From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: State of the overlay tree branch? Date: Mon, 19 Mar 2018 08:28:22 +0200 Message-ID: <831sggpojd.fsf@gnu.org> References: <834lldp18f.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1521440782 15983 195.159.176.226 (19 Mar 2018 06:26:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Mar 2018 06:26:22 +0000 (UTC) Cc: emacs-devel@gnu.org To: Sebastian Sturm Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 19 07:26:18 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exoFN-00044R-42 for ged-emacs-devel@m.gmane.org; Mon, 19 Mar 2018 07:26:17 +0100 Original-Received: from localhost ([::1]:40451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exoHP-0000Pg-Ts for ged-emacs-devel@m.gmane.org; Mon, 19 Mar 2018 02:28:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exoHK-0000PV-3X for emacs-devel@gnu.org; Mon, 19 Mar 2018 02:28:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exoHG-0007Xs-Sb for emacs-devel@gnu.org; Mon, 19 Mar 2018 02:28:18 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:49613) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exoHG-0007Xn-PK; Mon, 19 Mar 2018 02:28:14 -0400 Original-Received: from [176.228.60.248] (port=1928 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1exoHG-0002TO-6n; Mon, 19 Mar 2018 02:28:14 -0400 In-reply-to: (message from Sebastian Sturm on Sun, 18 Mar 2018 22:04:13 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:223802 Archived-At: > From: Sebastian Sturm > Date: Sun, 18 Mar 2018 22:04:13 +0100 > > I also found it surprising that overlays would slow down line counting, > but since I don't know anything about the architecture of the Emacs > display engine, or its overlay implementation, I figured that overlays > must be to blame because > > (i) the issue went away after switching to the feature/noverlay branch > > (ii) configuring the semantic highlighter to use its font-lock backend > also resolved the performance issue (though with the font-lock backend, > highlights are easily messed up by editing operations which makes the > overlay variant far more appealing) If you look at the implementation of count-lines, you will see it just calls forward-line, which pays no attention to overlays (as I'd expect). > I also found that some other heavy users of overlays such as > avy-goto-word-0-{above,below} feel faster with the feature/noverlay > branch, so I'd welcome a merge of the overlay branch even if there was a > technically superior alternative to line-number-at-pos that didn't > suffer from overlay-related performance issues. That's unrelated: we want to merge that branch when it's ready for several good reasons. But counting lines shouldn't be one of those reasons. > That being said, your suggestion sounds intriguing. What would be > required to expose find_newline to Lisp? Would I simply have to wrap it > in one of Emacs's DEFINE_ macros? DEFUN, more accurately. But yes. Actually, I see that forward-line already calls find_newline almost directly, so it should be fast enough. Exposing find_line should perhaps be able to produce some speedup (because you don't need to set point, like forward-line does), but I doubt that it would be significant. > Is there some documentation on the Emacs C backend? There's the "Writing Emacs Primitives" section of the "Internals" appendix. Turning back to your original problem, viz.: >> [1] I'm using cquery for my C++ editing needs, which comes with an >> overlay-based semantic highlighting mechanism. With my emacs >> configuration, lsp-mode/lsp-ui emit 6 calls to line-number-at-pos per >> character insertion, which consume ~20 to 25 ms each when performing >> edits close to the bottom of a 66KB C++ file (measured using >> (benchmark-run 1000 (line-number-at-pos (point))) on a release build of >> emacs-27/git commit #9942734...). Using the noverlay branch, this figure >> drops to ~160us per call. it looks strange to me that you get such long times. I just tried Emacs 26.0.91 near the end of xdisp.c (a 1MB file with over 33K lines), and I get 3 ms per call there. So I wonder how come you get 4 or 5 ms per call in a file that is 50 times smaller, because if I run the above benchmark with point at 70K, I get 0.16 ms per call. In an unoptimized build of the current master branch, I get 0.25 ms per call under these conditions. (And you could cache the result if you need 6 calls in the same vicinity, and after the initial call only call forward-line to compute relative increments.) This is with a 5-year old i7-2600 box with a 3.40 GHz clock. Is your CPU significantly slower?