From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Victor Nawothnig via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#49127: Performance degradation in encode_coding_object Date: Sun, 20 Jun 2021 08:30:24 +0200 Message-ID: Reply-To: Victor Nawothnig Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4942"; mail-complaints-to="usenet@ciao.gmane.io" To: 49127@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 20 10:19:16 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 1lusfk-00019P-AS for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 10:19:16 +0200 Original-Received: from localhost ([::1]:47064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lusfj-0006c4-By for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 04:19:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lusfY-0006bk-2M for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 04:19:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lusfX-00057B-RM for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 04:19:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lusfX-0000Cy-Jg for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 04:19:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Victor Nawothnig Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Jun 2021 08:19:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49127 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1624177134768 (code B ref -1); Sun, 20 Jun 2021 08:19:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Jun 2021 08:18:54 +0000 Original-Received: from localhost ([127.0.0.1]:32994 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lusfN-0000CJ-L8 for submit@debbugs.gnu.org; Sun, 20 Jun 2021 04:18:53 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:38224) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luqyZ-0003xI-EK for submit@debbugs.gnu.org; Sun, 20 Jun 2021 02:30:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luqyZ-0001qi-5E for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 02:30:35 -0400 Original-Received: from mr85p00im-zteg06023901.me.com ([17.58.23.192]:45945) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luqyW-0002c1-0A for bug-gnu-emacs@gnu.org; Sun, 20 Jun 2021 02:30:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1624170627; bh=On+gBYlSFol7/uYoWXY0dGO7ecWymoDIKqDDornfQDY=; h=Content-Type:From:Mime-Version:Subject:Message-Id:Date:To; b=xVclvyqhEW67enSt+g6bi7KGHfRX7bF8i0v8kxlhtT+gsRX9rH75zk93JFrxwRas1 mJbn6VAUhjYEi79jcaXio4ASKF6gwSw+R6E/F5PKWXvPIT+wAOOels5o/5d8o5DuQp JwacKkP5BDQ9PlbEbgvZNuqGX71VE1uzAJjN/JEjGR7r9vog/8qWwqmzbhSlVgtKug 21XGHkp3swu0cwQZOM72lTpaqGs95GomXPYDpQM6KNb4mwj7WDrPpmZXmWeP2kU8yQ fFsep5Fu8GAT5RxPVFSDMUzMsM4vK63onrelGT4kAXItTT0b+D8XAxzlxPGr6dbE02 1MgOLZTfsIZuA== Original-Received: from smtpclient.apple (p508bae06.dip0.t-ipconnect.de [80.139.174.6]) by mr85p00im-zteg06023901.me.com (Postfix) with ESMTPSA id 69BF768023F for ; Sun, 20 Jun 2021 06:30:27 +0000 (UTC) X-Mailer: iPad Mail (18F72) X-Proofpoint-Virus-Version: vendor=fsecure engine=1.1.170-22c6f66c430a71ce266a39bfe25bc2903e8d5c8f:6.0.391, 18.0.790, 17.0.607.475.0000000 definitions=2021-06-19_15:2021-06-18_01, 2021-06-19_15, 2020-04-07_01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 bulkscore=0 clxscore=1011 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2106200043 Received-SPF: pass client-ip=17.58.23.192; envelope-from=victor.nawothnig@icloud.com; helo=mr85p00im-zteg06023901.me.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_40=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 20 Jun 2021 04:18:53 -0400 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:208783 Archived-At: Hi, All of the following applies to Emacs 27.1 and 28.0.50. Im currently debugging a performance degradation in haskell-mode. When editi= ng code in a terminal frame, over time as I make modifications to source cod= e, redrawing lines during scrolling becomes continuously slower to the point= that it sometimes takes up 200ms for a single line to draw. This problem di= sappears once the GC runs. With gprof/prof_events I have nailed the problem to be encode_coding_object l= ooping over all markers. In degenerate cases this list can contain millions o= f markers. Traversing this list is particularly slow because of the indirect= ion being a singly linked list. Based on the fact that a GC remedies this, I= =E2=80=99m assuming this list contains mostly unreachable markers. When ste= pping through encode_coding_object with GDB after a GC this list of markers s= hrinks to small double digit numbers from millions. The source of these markers appears to be looking-at in the font locking cod= e of haskell-mode, this assumption is based on the fact that commenting out t= he uses of looking-at in haskell-mode prevents the accumulation of markers a= nd thus the slowdown. One contributing factor to all of this, is that for lsp-mode to perform adeq= uately, one needs a relatively high gc-cons-threshold, which means GCs that w= ould clean up the markers run more rarely, leading to higher accumulation of= markers over time. This problem only triggers in terminal frames, but not in GUI frames. Settin= g GDB breakpoints suggests that the GUI frame never even calls into encode_c= oding_object. So far I=E2=80=99m torn on whether this is a bug in the haskell-mode font lo= cking code or in Emacs. What do you think? Kind regards, Victor=