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, 20 Jun 2021 12:04:59 +0300 Message-ID: <83eecwvrd0.fsf@gnu.org> References: 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="8280"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49127@debbugs.gnu.org To: Victor Nawothnig Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 20 11:05:11 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 1lutOA-00022Y-TW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 11:05:10 +0200 Original-Received: from localhost ([::1]:50658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lutO9-00030M-Te for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 05:05:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lutO2-000303-DI for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 05:05:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lutO2-0000kX-5x for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 05:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lutO2-0003le-2R for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 05:05:02 -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, 20 Jun 2021 09:05:02 +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.162417989714461 (code B ref 49127); Sun, 20 Jun 2021 09:05:02 +0000 Original-Received: (at 49127) by debbugs.gnu.org; 20 Jun 2021 09:04:57 +0000 Original-Received: from localhost ([127.0.0.1]:33013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lutNw-0003lB-Q7 for submit@debbugs.gnu.org; Sun, 20 Jun 2021 05:04:57 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lutNu-0003kt-KS for 49127@debbugs.gnu.org; Sun, 20 Jun 2021 05:04:55 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34928) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lutNp-0000Za-AK; Sun, 20 Jun 2021 05:04:49 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2437 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 1lutNo-0000tD-Ti; Sun, 20 Jun 2021 05:04:49 -0400 In-Reply-To: (bug-gnu-emacs@gnu.org) 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:208784 Archived-At: > 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.