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#49127: Performance degradation in encode_coding_object Date: Sun, 25 Jul 2021 10:10:40 +0300 Message-ID: <835ywyyikv.fsf@gnu.org> References: <83eecwvrd0.fsf@gnu.org> <83y2azryvu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4408"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49127@debbugs.gnu.org To: victor.nawothnig@icloud.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 25 09:11:21 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 1m7YIC-00010u-Uv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Jul 2021 09:11:20 +0200 Original-Received: from localhost ([::1]:36908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7YIA-0001SC-Vb for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Jul 2021 03:11:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7YHu-0001Ro-3V for bug-gnu-emacs@gnu.org; Sun, 25 Jul 2021 03:11:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m7YHt-00032C-QU for bug-gnu-emacs@gnu.org; Sun, 25 Jul 2021 03:11:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m7YHt-0002iS-M5 for bug-gnu-emacs@gnu.org; Sun, 25 Jul 2021 03:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Jul 2021 07:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49127 X-GNU-PR-Package: emacs Original-Received: via spool by 49127-submit@debbugs.gnu.org id=B49127.162719705910431 (code B ref 49127); Sun, 25 Jul 2021 07:11:01 +0000 Original-Received: (at 49127) by debbugs.gnu.org; 25 Jul 2021 07:10:59 +0000 Original-Received: from localhost ([127.0.0.1]:47441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7YHq-0002iB-Vh for submit@debbugs.gnu.org; Sun, 25 Jul 2021 03:10:59 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7YHo-0002hv-I8 for 49127@debbugs.gnu.org; Sun, 25 Jul 2021 03:10:57 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:60728) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7YHj-0002ue-8E; Sun, 25 Jul 2021 03:10:51 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2617 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 1m7YHi-0003Yl-Sb; Sun, 25 Jul 2021 03:10:51 -0400 In-Reply-To: <83y2azryvu.fsf@gnu.org> (message from Eli Zaretskii on Thu, 24 Jun 2021 19:49:41 +0300) 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:210689 Archived-At: Ping! Ping! Please respond, so we could take care of this issue. To recap: I would like to have a backtrace from the call to encode_coding_object, including the Lisp backtrace (via the "xbacktrace" command), so that we could see how this performance issue happens. TIA > Date: Thu, 24 Jun 2021 19:49:41 +0300 > From: Eli Zaretskii > Cc: 49127@debbugs.gnu.org > > Ping! Could you please respond to my requests below? I'd like to > make some progress with this bug report. > > > Date: Sun, 20 Jun 2021 12:04:59 +0300 > > From: Eli Zaretskii > > Cc: 49127@debbugs.gnu.org > > > > > Date: Sun, 20 Jun 2021 08:30:24 +0200 > > > From: Victor Nawothnig via "Bug reports for GNU Emacs, > > > the Swiss army knife of text editors" > > > > > > With gprof/prof_events I have nailed the problem to be encode_coding_object looping over all markers. In degenerate cases this list can contain millions of markers. Traversing this list is particularly slow because of the indirection being a singly linked list. Based on the fact that a GC remedies this, I’m assuming this list contains mostly unreachable markers. When stepping through encode_coding_object with GDB after a GC this list of markers shrinks to small double digit numbers from millions. > > > > > > The source of these markers appears to be looking-at in the font locking code of haskell-mode, this assumption is based on the fact that commenting out the uses of looking-at in haskell-mode prevents the accumulation of markers and thus the slowdown. > > > > Do you understand why using looking-at causes creation of markers? If > > so, can you show the details of why this happens? > > > > > One contributing factor to all of this, is that for lsp-mode to perform adequately, one needs a relatively high gc-cons-threshold, which means GCs that would clean up the markers run more rarely, leading to higher accumulation of markers over time. > > > > Yes, playing with GC threshold is usually a bad idea, but it is hard > > to explain to people why, and they keep doing that, to their cost. > > > > > This problem only triggers in terminal frames, but not in GUI frames. Setting GDB breakpoints suggests that the GUI frame never even calls into encode_coding_object. > > > > Can you should a backtrace from the call to encode_coding_object, > > including the Lisp backtrace (via the "xbacktrace" command)? > > > > > So far I’m torn on whether this is a bug in the haskell-mode font locking code or in Emacs. What do you think? > > > > Let's revisit this question after we have all the data I requested > > above, okay? > > > > Thanks. > > > > > > > > > > > > >