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.devel Subject: Re: Ligature support Date: Sat, 06 Nov 2021 10:32:33 +0200 Message-ID: <83sfw9bs66.fsf@gnu.org> References: <87cznths5j.fsf@gnus.org> <8ff3b131c57f741d04e5@heytings.org> <83lf2drqx6.fsf@gnu.org> <87lf2c3k0z.fsf@gnus.org> <83wnlwqocq.fsf@gnu.org> <87wnlwyox9.fsf@gnus.org> <83lf2cq7n5.fsf@gnu.org> <87wnlnkxbo.fsf@gnus.org> <83cznfdohr.fsf@gnu.org> <87zgqik9bk.fsf@gnus.org> <83v916d64z.fsf@gnu.org> <878ry2k6qz.fsf@gnus.org> <83tugqd488.fsf@gnu.org> <87zgqiiq8c.fsf@gnus.org> <83r1bud3or.fsf@gnu.org> <87r1buipf5.fsf@gnus.org> <83o86yd0ig.fsf@gnu.org> <87a6iiimay.fsf@gnus.org> <83fssact8i.fsf@gnu.org> <87k0hmgre3.fsf@gnus.org> <87fssagqub.fsf@gnus.org> <87bl2ygq8u.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16693"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 06 09:33:46 2021 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 1mjH8y-00047l-VW for ged-emacs-devel@m.gmane-mx.org; Sat, 06 Nov 2021 09:33:45 +0100 Original-Received: from localhost ([::1]:59470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjH8x-0002zC-3w for ged-emacs-devel@m.gmane-mx.org; Sat, 06 Nov 2021 04:33:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjH8C-0002JB-HQ for emacs-devel@gnu.org; Sat, 06 Nov 2021 04:32:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:38114) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjH8C-0001so-67; Sat, 06 Nov 2021 04:32:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=QGnwMW5fPRIcF078R98ct65gQ8IwLaJvDLSYG7jRzT8=; b=nsPqcXpuXgvD awWg5V7rtxvU2ux2yppkuRNTbu+Hukw53gdYhYHy43MZdBqe2P4/nayJL9uYEMOdxT88FAgGoGhxW /SRmeEE1o4QhkbHHPo3b2BDNxlGrwmqirR3dioL0hi4L0oUPkgQMTxW9pY3lbt1oJkTawN8mlVkkM 9ZVPEEqd6HgktYiLEOOdgjbl8B6V8bC3vS/2oj8byZrFisetzWJBXuyqm/59KPwY+XX0/tgCzJM/8 azB0FZqxqUR4quPW1gUsPoc3Q9ksrvxazd3ZP5TQgKFM9gQZ3CX0LVRWw3+QJ5JRiLn6pyKetAEJw N2meSzi7FOv30NAVui3TeQ==; Original-Received: from [87.69.77.57] (port=4289 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 1mjH85-0001kx-4Z; Sat, 06 Nov 2021 04:32:52 -0400 In-Reply-To: <87bl2ygq8u.fsf@gnus.org> (message from Lars Ingebrigtsen on Sat, 06 Nov 2021 00:02:57 +0100) 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: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:278848 Archived-At: > From: Lars Ingebrigtsen > Cc: emacs-devel@gnu.org > Date: Sat, 06 Nov 2021 00:02:57 +0100 > > (dolist (c (append (number-sequence ?A ?Z) > (number-sequence ?a ?z))) > (aset composition-function-table > c > (list (vector (concat (string c) "[^ \n\t]+") 0 #'font-shape-gstring)))) > > So that fixes the kerning (this is with the proportional Deja Vu font). > And with that, scrolling through xdisp.c is 30% slower. 30% slowdown is already a bad sign. However, scrolling through xdisp.c is not representative enough, since most of that is source code which will not ligate given the above rules. If you want to make a realistic comparison for xdisp.c, you need ligature rules for program symbols, not for ASCII letters. I tried the above with the King James Bible text, which you can download from here: http://corpus.canterbury.ac.nz/resources/large.tar.gz It's a 30K line, 4MB file. With that, running the scrolling benchmark whose code is shown below produces: without ligatures: 30.4 sec and 28 GC cycles with ligatures: 91.1 sec and 91 GC cycles (This is an unoptimized build of Emacs 29; with optimized builds and/or faster CPUs you will see shorter times, but the ratio should be similar.) Are we willing to make our redisplay 3 times slower with plain ASCII text? I think the current design of character compositions in Emacs is inappropriate for sending all the text via the shaping engine. It was designed on the assumption that composed characters will be rare in "normal" usage, and will only be massive in some specific scripts where this is unavoidable, like Arabic and Hangul. If we want to call the shaper for everything we display, we should radically change how this is designed and implemented. Here's the function I used for the benchmark: (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))))))