From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Akib Azmain Turja via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59641: term is very slow Date: Sat, 17 Dec 2022 18:32:09 +0600 Message-ID: <87ilia2oty.fsf@disroot.org> References: <878rjwmale.fsf@disroot.org> <835yf0p2ba.fsf@gnu.org> <87zgbn2oep.fsf@disroot.org> <83pmcji3bu.fsf@gnu.org> Reply-To: Akib Azmain Turja Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30159"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59641@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 17 15:46:21 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 1p6YSD-0007cZ-2c for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Dec 2022 15:46:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6YRw-00054f-N8; Sat, 17 Dec 2022 09:46:04 -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 1p6YRv-00054W-1h for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 09:46:03 -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 1p6YRu-0006XT-Q3 for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 09:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p6YRu-0001h0-8X for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 09:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Akib Azmain Turja Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Dec 2022 14:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59641 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 59641-submit@debbugs.gnu.org id=B59641.16712883596500 (code B ref 59641); Sat, 17 Dec 2022 14:46:02 +0000 Original-Received: (at 59641) by debbugs.gnu.org; 17 Dec 2022 14:45:59 +0000 Original-Received: from localhost ([127.0.0.1]:56281 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6YRq-0001gm-Gf for submit@debbugs.gnu.org; Sat, 17 Dec 2022 09:45:59 -0500 Original-Received: from knopi.disroot.org ([178.21.23.139]:52154) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6YRo-0001gg-AG for 59641@debbugs.gnu.org; Sat, 17 Dec 2022 09:45:57 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id E5A6F411F7; Sat, 17 Dec 2022 15:45:54 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Original-Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ib9xpxRdx0lu; Sat, 17 Dec 2022 15:45:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1671288353; bh=vZGF+gbeMr428gd4G0DDPlyrCb2yYdDyhpuaDb3kDQw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=Q/zcR8s5BUk/i01CNtdieBr/HJbmbiF4tCR6+FdXW+zvRXsi29VfHZ83ZBhh0IYP7 aBqpJpWT78/7YwDTfcxSouATGVOdz6XG4LaCz9JqDFOajNpYPMODa2nI3Bw3ArcHHS VQq64lFidEcAj2vPEPYSA0BYIuyXlr4J4TPki6z4Evmsg+B92P5423GrBtkNrrfNn7 xI0qG6CETgUWmzSKI6uIzhA8HVrgtSdp+RuwHPdwceUkSBvRBtf0bucVI57SBx/Ylh gk6BNN9HvE24CS58W6ev8SVkKj+RysHn3Q4TXLtq8LIjynD6PQ/zxfFTgef4uCP/iz JnKNDkp6UCqcA== In-Reply-To: <83pmcji3bu.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 16 Dec 2022 20:57:41 +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:251282 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I missed this again! There is definitely something wrong. Anyway... Eli Zaretskii writes: >> From: Akib Azmain Turja >> Cc: 59641@debbugs.gnu.org >> Date: Sat, 17 Dec 2022 00:29:02 +0600 >>=20 >> >> Here are the reports (attached), but don't seem to be human readable: >> > >> > Copy them from the display shown by profiler-report, after you expand = it >> > completely. >> > >> > And the "cpu" profile is enough; the "mem" one doesn't add anything us= eful. >>=20 >> Sorry, I missed this reply. I found this in debbugs.gnu.org. :O >>=20 >> Here is the data: (I didn't redo the steps, I just did >> 'M-x profiler-find-profile RET path/to/profile'. ;) ) >>=20 >> --8<---------------cut here---------------start------------->8--- >> 9397 95% - term-emulate-terminal >> 2710 27% - term-handle-ansi-escape >> 1831 18% - term-down >> 8 0% term-move-columns >> 765 7% - term-goto > > Doesn't surprise me: most of the time is spent in term.el's business > logic, not in Emacs display primitives. I know that very well. > > If you want to work on speeding up term.el, I suggest to start by > loading term.el (not term.elc) manually, and repeating the profiling > session. That could tell you in more detail where are the hot sports > in those functions at the top of the profile. Then some clever > optimization ideas are needed to make it significantly faster. > > Thanks. I guess the hot spot here is 'vertical-motion'. 'vertical-motion' takes various things into account, which are unnecessary for a terminal emulator. Eat implements its own motion functions, which make their own assumptions (e.g. each character takes exactly one column, each line finishes with a newline, etc). I guess this might be a reason why Eat is faster. Note that I'm the author of Eat, and Term is a direct competitor of Eat. So although I want Term to be faster, I will be of course biased if I try to improve Term. But don't get me wrong, I really want Term to do better; competition is fun when you have tough competitors! Here is the CPU profile data, with 'term.el' loaded: =2D-8<---------------cut here---------------start------------->8--- 1551 87% - term-emulate-terminal 1551 87% - if 1551 87% - progn 1551 87% - save-current-buffer 1515 85% - let* 1515 85% - let 1515 85% - save-current-buffer 1515 85% - unwind-protect 1515 85% - progn 1361 76% - save-restriction 1361 76% - while 1341 75% - let 1130 63% - let* 1126 63% - cond 1126 63% - let 586 33% - funcall 108 6% - vertical-motion 100 5% - jit-lock-function 84 4% - jit-lock-fontify-now 64 3% - jit-lock--run-functions 24 1% - # 24 1% - font-lock-fontify-region 24 1% font-lock-default-fontify-region 20 1% - # 20 1% font-lock-fontify-region 4 0% - # 4 0% - font-lock-fontify-region 4 0% - font-lock-default-fontify-region 4 0% - font-lock-extend-region-wholelin= es 4 0% syntax-propertize-wholelines 4 0% # 4 0% - # 4 0% - font-lock-fontify-region 4 0% - font-lock-default-fontify-region 4 0% # 532 30% - if 528 29% - term-down 528 29% - let 344 19% - if 304 17% - if 304 17% - progn 304 17% - setq 300 16% - - 300 16% - funcall 56 3% - vertical-motion 52 2% - jit-lock-function 48 2% - jit-lock-fontify-now 32 1% - jit-lock--run-functions 12 0% - # 12 0% font-lock-fontify-region 8 0% - # 8 0% - font-lock-fontify-region 8 0% font-lock-default-fontify= -region 8 0% - # 8 0% - font-lock-fontify-region 8 0% - font-lock-default-fontify= -region 8 0% font-lock-extend-region-= wholelines 28 1% - progn 28 1% - term-move-columns 28 1% - term-move-to-column 28 1% let 4 0% - and 4 0% =3D 4 0% term-adjust-current-row-cache 184 10% - cond 176 9% - term-insert-char 172 9% - let 56 3% - put-text-property 20 1% jit-lock-after-change 4 0% syntax-ppss-flush-cache 48 2% - insert-char 20 1% jit-lock-after-change 4 0% and 203 11% - if 187 10% - progn 147 8% - let 24 1% - progn 24 1% setq 24 1% - put-text-property 8 0% jit-lock-after-change 20 1% - insert 8 0% jit-lock-after-change 4 0% - term-horizontal-column 4 0% - - 4 0% - term-current-column 4 0% - cond 4 0% setq 8 0% setq 8 0% if 16 0% setq 136 7% - if 136 7% - progn 136 7% - term-handle-deferred-scroll 136 7% - let 136 7% - if 136 7% - progn 136 7% - save-excursion 136 7% funcall 18 1% - while 18 1% - progn 18 1% - if 18 1% - progn 18 1% - let 18 1% - if 18 1% - progn 18 1% - if 18 1% not 36 2% - if 36 2% - progn 36 2% - redisplay 4 0% - redisplay_internal (C function) 4 0% - eval 4 0% if 171 9% - ... 171 9% Automatic GC 40 2% - command-execute 22 1% - byte-code 22 1% - read-extended-command 22 1% - read-extended-command-1 8 0% completing-read-default 18 1% - funcall-interactively 10 0% - minibuffer-complete 10 0% - completion-in-region 10 0% - completion--in-region 6 0% - # 6 0% - apply 6 0% - # 6 0% - completion--in-region-1 6 0% - completion--do-completion 6 0% - completion-try-completion 6 0% - completion--nth-completion 6 0% - completion--some 6 0% - # 6 0% - completion-basic-try-completion 6 0% - # 6 0% complete-with-action 4 0% - # 4 0% - apply 4 0% - # 4 0% - completion--in-region-1 4 0% - completion--do-completion 4 0% - completion-try-completion 4 0% - completion--nth-completion 4 0% - completion--some 4 0% - # 4 0% - completion-pcm-try-completion 4 0% - completion-pcm--find-all-completions 4 0% - completion-pcm--all-completions 4 0% - # 4 0% complete-with-action 8 0% - execute-extended-command 8 0% - command-execute 8 0% funcall-interactively 7 0% - timer-event-handler 7 0% - apply 4 0% # 3 0% - # 3 0% execute-extended-command--shorter 2 0% - redisplay_internal (C function) 2 0% - term--update-term-menu 2 0% - if 2 0% - progn 2 0% - let 2 0% - easy-menu-change 2 0% - mapcar 2 0% - # 2 0% - vector 2 0% format =2D-8<---------------cut here---------------end--------------->8--- =2D-=20 Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5 Fediverse: akib@hostux.social Codeberg: akib emailselfdefense.fsf.org | "Nothing can be secure without encryption." --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEyVTKmrtL6kNBe3FRVTX89U2IYWsFAmOdtsoACgkQVTX89U2I YWtmnxAA0aDTji/mnlTvxNKdCx82nJwPPiBYroqoKZ3vWVPvMi9uP1XPxmdx0HUL hHOjPeO/olJqXnBpMS4yxcGlwDMx9Et8atFHeBsAeJPbIeAn463NhVIJXdX1HL5b NW3jqXYLqAPsXn8rjp6gAnn0lX7OKopYc0IFYv9e98sIySPx22FiyGzo68XuDsYJ +mRniqBcYSMDtusPYcd3M/fqzC4g7G9OsYa8d5xvsI6XZqXPzHbfpO3gCoQ6T3RM iunYi8xcu5S0Y0B6fyPr4ZXDBUQSw5YsVqKBhrwGjMdPAv7RUYPE/7HaFPaWFdXX 7MjFHlDkxlZYy0klZLhyrfY/roIWA4o5GLE6RGmx+f1j/99KNlFx0Sazjnm63O3x uo6rLXpPxVLcjI1+ua8ieWzxqVkPjFD0F+hmFAd294T9ApI7M59+Qgx7H/5R2jv9 G65YH1mDEySFQ48nSlcQRcfqnORQsdFOssTZB6Szt1fR9Av9hl69foELGZmOpONS FHd6ssY3kmnKs8+rUfUj+o8CG5jcHINKzX1Onqf3niuG6x6hhoYYRvz3P6cq8XHs FBT7BSwTonG87IFpqBkNpBRUi4reJapyXL0SaTpC+n7cJ9Hlifv46kHzOByf9xgL o9e9RMWtpvIwStKyyPE1bfwe2hTU0he6Tb1mx0jkOtt1c4wGjos= =KZ9k -----END PGP SIGNATURE----- --=-=-=--