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.bugs Subject: bug#48734: 28.0.50; Performance regression in `string-width`? Date: Sun, 30 May 2021 13:00:32 +0300 Message-ID: <83eedo4k3j.fsf@gnu.org> References: <87a6odmfp6.fsf@teknik.io> <83o8cs4t9m.fsf@gnu.org> <87y2bwk1nj.fsf@teknik.io> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4581"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48734@debbugs.gnu.org To: Imran Khan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 30 12:01:20 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 1lnIFz-00011B-Oa for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 12:01:19 +0200 Original-Received: from localhost ([::1]:48258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnIFy-0006WN-Rh for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 06:01:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnIFk-0006Vz-UT for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 06:01:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46874) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnIFi-0004S6-Cm for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 06:01:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lnIFi-0004xM-8s for bug-gnu-emacs@gnu.org; Sun, 30 May 2021 06:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 May 2021 10:01: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.162236883219009 (code B ref 48734); Sun, 30 May 2021 10:01:02 +0000 Original-Received: (at 48734) by debbugs.gnu.org; 30 May 2021 10:00:32 +0000 Original-Received: from localhost ([127.0.0.1]:58420 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnIFE-0004wX-HH for submit@debbugs.gnu.org; Sun, 30 May 2021 06:00:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lnIFA-0004wG-B0 for 48734@debbugs.gnu.org; Sun, 30 May 2021 06:00:31 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:36668) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnIF4-000430-WA; Sun, 30 May 2021 06:00:23 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3173 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 1lnIF4-0006gN-I4; Sun, 30 May 2021 06:00:22 -0400 In-Reply-To: <87y2bwk1nj.fsf@teknik.io> (message from Imran Khan on Sun, 30 May 2021 15:32:16 +0600) 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:207602 Archived-At: > From: Imran Khan > Date: Sun, 30 May 2021 15:32:16 +0600 > > > Since you use insert-file-contents-literally, why don't you also make > > the temporary buffer unibyte? That is: > > > > (benchmark-run 1 > > (let ((str)) > > (with-temp-buffer > > (set-buffer-multibyte nil) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<< > > (insert-file-contents-literally "/tmp/test") > > (setq str (buffer-string))) > > (string-width str))) > > > > Or maybe I don't understand your real-life use case? Because if you > > treat the file as a raw bytestream, why do you need to compute the > > width of its text? > > I would agree, my example was pointlessly contrived. For what it's > worth, `insert-file-contents` exhibits same poor performance, and that's > used by code in the wild (e.g. deft-mode, though I am sceptical if they > should be needing to call `string-width` on entire buffer text either). > > Personally I am now going to use your `(set-buffer-multibyte nil)` > suggestion to patch their code for myself (so thanks for this). Since > I have no idea about the internal complexity of `string-width` or what > should be justified performance expectation, I would let you decide if > this is a bug or not. I'm not yet sure whether this is a real problem, because I don't really understand the relation between your example code and what you really need to do in deft-mode. Specifically, generating random characters isn't something that usually happens in real life. So could you perhaps explain what you are using string-width for in deft-mode, and what kind of text are you measuring there in your real-life situations? Thanks. P.S. Please use Reply All to keep the bug address on the CC list.