From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Imran Khan Newsgroups: gmane.emacs.bugs Subject: bug#48734: 28.0.50; Performance regression in `string-width`? Date: Mon, 31 May 2021 18:36:40 +0600 Message-ID: <87y2bvozaf.fsf@teknik.io> References: <87a6odmfp6.fsf@teknik.io> <83o8cs4t9m.fsf@gnu.org> <87y2bwk1nj.fsf@teknik.io> <83eedo4k3j.fsf@gnu.org> <87v970jwik.fsf@teknik.io> <835yz04ean.fsf@gnu.org> <87r1hoza6z.fsf@gnus.org> <834kek4aai.fsf@gnu.org> <87h7ijlats.fsf@gnus.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="21692"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48734@debbugs.gnu.org To: Lars Ingebrigtsen , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 31 14:37:23 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 1lnhAZ-0005Qt-6O for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 14:37:23 +0200 Original-Received: from localhost ([::1]:49566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnhAY-0002PR-9K for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 08:37:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnhAG-0002G4-0T for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 08:37:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnhAE-00006l-CX for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 08:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lnhAE-0007FA-AF for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 08:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Imran Khan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 May 2021 12:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48734 X-GNU-PR-Package: emacs Original-Received: via spool by 48734-submit@debbugs.gnu.org id=B48734.162246461227813 (code B ref 48734); Mon, 31 May 2021 12:37:02 +0000 Original-Received: (at 48734) by debbugs.gnu.org; 31 May 2021 12:36:52 +0000 Original-Received: from localhost ([127.0.0.1]:32938 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnhA4-0007EW-EX for submit@debbugs.gnu.org; Mon, 31 May 2021 08:36:52 -0400 Original-Received: from mail-pg1-f171.google.com ([209.85.215.171]:38481) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnhA2-0007EK-Iu for 48734@debbugs.gnu.org; Mon, 31 May 2021 08:36:51 -0400 Original-Received: by mail-pg1-f171.google.com with SMTP id 6so8256888pgk.5 for <48734@debbugs.gnu.org>; Mon, 31 May 2021 05:36:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=I7JdkqUTW4Lm6LVxrt5h8N26PsGWyjXj/06vFVxabNM=; b=j3ERetKmAkscCGX7dXBbOcGxZZDAU4hS1t7dgfDyC6PjsHAJ6EKpgb+Ak9wBI/EWRS +02PXeinMfck5iuCfoiUm/9LbcpoKAGelPIBNP+SG0EsOsetFEN2dSuBPWAT7lUgESrU a6rSngHnQncgT4oiBz4I8QAFF0lFh9mtNs9IMIzCDRUFOTIGmh6xcECz6/eh5xhgIFJb zDNYZ0i1rmxALRwc+9jWrSjw9ozCw+5a6fRrVPupJn4uapM2z8w27gWVjfV18INavY9F rYiDYUQS3IBK3nnntZAO6EhSBJDWQX7xV1oFWmeFvv+z+8FuDP685kInB6jW2P9IFwhw hmrA== X-Gm-Message-State: AOAM5317knp5FoeAeiGmqjM3OwvWRmWA84LYzG3sdtgIq2KvyS3d2zJT flM25yMi/uYUNPCXKtwgDJk= X-Google-Smtp-Source: ABdhPJwel3pEH4/5RgzU+1ubbhfeT9qF7goniHUGYT70kq01qtcgdEF5t6DgmmLYhSm4i6m5LhNaAQ== X-Received: by 2002:a62:2bc6:0:b029:2cc:242f:ab69 with SMTP id r189-20020a622bc60000b02902cc242fab69mr16846711pfr.16.1622464604717; Mon, 31 May 2021 05:36:44 -0700 (PDT) Original-Received: from localhost ([116.206.252.68]) by smtp.gmail.com with ESMTPSA id o17sm10707227pjp.33.2021.05.31.05.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 05:36:44 -0700 (PDT) In-Reply-To: <87h7ijlats.fsf@gnus.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:207695 Archived-At: Lars Ingebrigtsen writes: > Eli Zaretskii writes: > >> FWIW, I did measure the speed after the change, and saw only something >> like 10% slowdown for strings with composable characters. Maybe my >> tests were skewed, or maybe there are other use cases I didn't think >> about. > > Yes, Imran's test case here was very synthetic -- Imran, what does the > actual strings in deft where you see these slowdowns look like? Do you > have some examples you can share? > > -- > (domestic pets only, the antidote for overdose, milk.) > bloggy blog: http://lars.ingebrigtsen.no I can't share my personal files for privacy reasons, but I don't think there is anything remarkable about them, it's just prose so any utf-8 file would do. Let's go with Grimm's Fairy Tales from Project Gutenberg. https://www.gutenberg.org/files/2591/2591-0.txt I find that, this is actually fine: (benchmark-run 1 (let ((str)) (with-temp-buffer (insert-file-contents "~/2591-0.txt") (setq str (buffer-string))) (print (string-width str)))) ;;;; 0.5s here, fast enough But I believe what triggers the hanging behaviour for deft-mode is that they are doing (among other things) a text transformation of stripping all vertical whitespace in string to make it look flat: https://github.com/jrblevin/deft/blob/c4af44827f4257e7619e63abfd22094a29a9ab52/deft.el#L678 Which we can replicate with string-replace: (benchmark-run 1 (let ((str)) (with-temp-buffer (insert-file-contents "~/2591-0.txt") (setq str (string-replace "\n" " " (buffer-string)))) (print (string-width str)))) ;;;; beware this now hangs I waited a minute for it to finish before killing Emacs. Hope that helps.