From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: CC Mode -> Tree sitter challenge Date: Sat, 05 Nov 2022 14:12:14 +0100 Message-ID: <87mt951r69.fsf@thornhill.no> References: <87v8nu1mt1.fsf@thornhill.no> <83eduh4vcf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27984"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 05 14:13:16 2022 Return-path: Envelope-to: ged-emacs-devel@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 1orIz6-00073o-HD for ged-emacs-devel@m.gmane-mx.org; Sat, 05 Nov 2022 14:13:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1orIyI-0007K7-Bf; Sat, 05 Nov 2022 09:12:26 -0400 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 1orIyD-0007IH-Mn for emacs-devel@gnu.org; Sat, 05 Nov 2022 09:12:24 -0400 Original-Received: from out0.migadu.com ([94.23.1.103]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1orIyB-00059a-8F; Sat, 05 Nov 2022 09:12:21 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1667653936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pPGf9CxWyOSHcwEFW5+PGaxWnJqo7E1LJs4RzZKv+vk=; b=LeslSN4ZVg1+/EJbBKYKRtIxCr/CNkF5IvbU2OP65+88Qhch7sCDoY3Nj2YGbfblkmV0C3 QLBgNDLDYv9XYYiEtyjPkNwtK8SuiapDGJEVRRg9o2u0pADEe9x/ugfYU7Bt27UeJHDsMN ShiEp2xBXODplAcxOKAvposuF7Ez0TqxZquBQPMqXknk3o5MvuVcQ87/xxJN7rOkCBOnJu cOgTzDBqvt7/NAn/1yBst8H84XtY8hTmpR0GmWZo4ERORA2pbLLOkEfoSd68uSnJTkF8F8 hIbuSg5B5Sc3qwLFgWac14LlBBlSGPs5/P37x2R4tEXXFFdT4ZthZaGFGbdhmw== In-Reply-To: <83eduh4vcf.fsf@gnu.org> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=94.23.1.103; envelope-from=theo@thornhill.no; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:299197 Archived-At: Hi Eli, [...] >> - TypeScript (left out, as it is in tree-sitter branch already) > > Thanks. My pleasure. >> 2. I've focused mostly on indentation and font locking. Indentation is >> using xdisp code style and the gnu style in general. > > We should ideally support all the indentation styles supported by CC > Mode. > Yes, I'll try to be as comprehensive as possible. >> When scrolling through xdisp with this variant of C support it is >> noticeably faster on my system. However, I'd like some guidance on how >> to provide some benchmarks to prove my guess. > > We usually use something like the below: Thanks, I used them, see results below. > The instructions are: visit xdisp.c and immediately invoke one of > these two functions; then record the time it took to scroll through > the entire file. Compare to CC Mode. > > I think we also want to see the above modified to make some change to > the buffer once in a while. For example, once in 100 lines insert a > quote ", or a /* followed by */ after several lines, and see how that > affects the scroll times with both modes. > >> Loading said file and immediately going to EOB is instant, but in CC >> Mode takes a little less than a second. > > Timing this with benchmark-run and presenting the numbers is also > interesting. So this is the code with results thus far. It is immediately apparent how much faster this is, IMO. Every test is run from a fresh `emacs -Q`. I just eval the files, enable the modes and run the tests. What do you think? Is there anything clearly wrong with the benchmarks? In many of the cases tree-sitter is an order of magnitude faster. ``` (defun scroll-up-benchmark () (interactive) (let ((oldgc gcs-done) (oldtime (float-time))) (condition-case nil (while t (scroll-up) (redisplay)) (error (message "GCs: %d Elapsed time: %f seconds" (- gcs-done oldgc) (- (float-time) oldtime)))))) (defun scroll-up-by-40-benchmark () (interactive) (let ((oldgc gcs-done) (oldtime (float-time))) (condition-case nil (while t (scroll-up 40) (redisplay)) (error (message "GCs: %d Elapsed time: %f seconds" (- gcs-done oldgc) (- (float-time) oldtime)))))) (defun scroll-up-insert-quote-benchmark () (interactive) (let ((oldgc gcs-done) (oldtime (float-time))) (condition-case nil (while t (scroll-up 50) (when (zerop (mod (1- (line-number-at-pos)) 100)) (insert "\"")) (redisplay)) (error (message "GCs: %d Elapsed time: %f seconds" (- gcs-done oldgc) (- (float-time) oldtime)))))) (defun xdisp-eob-benchmark () (benchmark-run 100 (progn (with-current-buffer (find-file "~/src/emacs/src/xdisp.c") (end-of-buffer)) (kill-buffer "xdisp.c")))) ;; C-MODE ;; scroll-up-benchmark ;; 1: GCs: 402 Elapsed time: 17.499269 seconds ;; 2: GCs: 415 Elapsed time: 17.789382 seconds ;; scroll-up-by-40-benchmark ;; 1: GCs: 420 Elapsed time: 19.183639 seconds ;; 2: GCs: 420 Elapsed time: 19.377480 seconds ;; xdisp-eob-benchmark 100 ;; 1: (40.992420494 1708 16.708356162) ;; 2: (40.630712261 1711 16.361947911999998) ;; xdisp-eob-benchmark 1 ;; 1: (0.482883063 21 0.19676500600000002) ;; 2: (0.478595514 21 0.19573110300000002) ;; scroll-up-insert-quote-benchmark ;; 1: GCs: 558 Elapsed time: 41.747822 seconds ;; 2: GCs: 557 Elapsed time: 41.976805 seconds ;; C-TS-MODE ;; scroll-up-benchmark ;; 1: GCs: 21 Elapsed time: 6.997570 seconds ;; 2: GCs: 27 Elapsed time: 7.239952 seconds ;; scroll-up-by-40-benchmark ;; 1: GCs: 30 Elapsed time: 8.869021 seconds ;; 2: GCs: 29 Elapsed time: 9.076617 seconds ;; xdisp-eob-benchmark 100 ;; 1: (15.083917789 20 1.1350005760000001) ;; 2: (15.213992551999999 21 1.121564519) ;; xdisp-eob-benchmark 1 ;; 1: (0.19189711499999998 1 0.011011572999999997) ;; 2: (0.185749092 1 0.011173242) ;; scroll-up-insert-quote-benchmark ;; 1: GCs: 29 Elapsed time: 15.450495 seconds ;; 2: GCs: 29 Elapsed time: 12.168593 seconds ``` Theo