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: Sun, 30 May 2021 02:45:57 +0600 Message-ID: <87a6odmfp6.fsf@teknik.io> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38481"; mail-complaints-to="usenet@ciao.gmane.io" To: 48734@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 30 00:19:33 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 1ln7Iq-0009m1-Ru for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 May 2021 00:19:32 +0200 Original-Received: from localhost ([::1]:54414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ln7Ip-0006nE-Vd for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 May 2021 18:19:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ln7IP-0006mx-BQ for bug-gnu-emacs@gnu.org; Sat, 29 May 2021 18:19:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46378) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ln7IM-0006lv-44 for bug-gnu-emacs@gnu.org; Sat, 29 May 2021 18:19:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ln7IM-0005CN-0H for bug-gnu-emacs@gnu.org; Sat, 29 May 2021 18:19: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: Sat, 29 May 2021 22:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48734 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162232668219901 (code B ref -1); Sat, 29 May 2021 22:19:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 May 2021 22:18:02 +0000 Original-Received: from localhost ([127.0.0.1]:57923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ln7HM-0005AZ-R6 for submit@debbugs.gnu.org; Sat, 29 May 2021 18:18:02 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:35810) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ln5qU-0000ik-H3 for submit@debbugs.gnu.org; Sat, 29 May 2021 16:46:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ln5qQ-0003MP-VI for bug-gnu-emacs@gnu.org; Sat, 29 May 2021 16:46:10 -0400 Original-Received: from mail-pf1-f173.google.com ([209.85.210.173]:37506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ln5qP-0006jb-1T for bug-gnu-emacs@gnu.org; Sat, 29 May 2021 16:46:06 -0400 Original-Received: by mail-pf1-f173.google.com with SMTP id y15so1988675pfl.4 for ; Sat, 29 May 2021 13:46:04 -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:subject:date:message-id:mime-version :content-transfer-encoding; bh=/P6EKG1wu8/9lFu0f27c9DXOHZCzo+FYvQ+6Y5xsoDM=; b=OZt8PmjIKmbqEgX0baz+9L4wjSc1yxQI5MEcq9FUHc1I8KEaaZpGebSVqNoEChotHm Uax9F2w+0vPUEvO2lrTu8Xtj58bglan8AHXRu4giXQNxELcRpYu6qo8G9pkwWzbPIPTy +feDrzXPaQtbo94sF+DfAV+KMDffKHH/wCVFXjlFoT57/FGT5uBPxf0B7zHxLyhdA41p Xfx2F6Mbmsddtp284A1K81/pT5qFTwkZgDu0O2ProIYgL3kFZIZaKmb6FrLzI8E/T4Gh 3bG1G13Z3et1SQxJUju74j8+xlcw8LQlBi5Tvu43bLb0vR2CldCRigi56rATGiXOTWOD /Q5w== X-Gm-Message-State: AOAM5312lqQCKc7wmsOp6sjVzaSr0LzW4UMzW+74646btewmPjXS6KTJ jDAYDIaaKfehNcGtMTk3Y/JdEYPpI/A= X-Google-Smtp-Source: ABdhPJz+UBL6SGmmnc0PWw36wMnUeWKNWMbcRkjA7zmGT3AX0A91O5KmZqREHdAUwbFkOCkrCBhhNQ== X-Received: by 2002:a62:7c12:0:b029:2d9:a70:2b9c with SMTP id x18-20020a627c120000b02902d90a702b9cmr10070280pfc.22.1622321162578; Sat, 29 May 2021 13:46:02 -0700 (PDT) Original-Received: from localhost ([116.206.252.68]) by smtp.gmail.com with ESMTPSA id f64sm404691pjk.22.2021.05.29.13.46.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 May 2021 13:46:02 -0700 (PDT) Received-SPF: pass client-ip=209.85.210.173; envelope-from=natrys13@gmail.com; helo=mail-pf1-f173.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 29 May 2021 18:17:59 -0400 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:207557 Archived-At: A package I use (deft-mode) has been hanging for minutes with high cpu use recently. Profiler says most time is spent in `string-width`, and upon looking it seems to happen in files that have multibyte characters in them. I reproduced the problem by creating a file that has both single and multi byte characters: with open("/tmp/test", "w") as f: for i in range(50_000): print("1", file=3Df, end=3D"") print("=CE=B1", file=3Df, end=3D"") And now: (benchmark-run 1 (let ((str)) (with-temp-buffer (insert-file-contents-literally "/tmp/test") (setq str (buffer-string))) (string-width str))) This takes 20 seconds in my machine (if string is exclusively full of either single or multibyte characters, weirdly it seems to finish instantly). -------- In GNU Emacs 28.0.50 (build 1, x86_64-unknown-linux-gnu, X toolkit, cairo v= ersion 1.16.0) of 2021-05-29 built on 9d4a5f294007 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: void Configured using: 'configure --with-x-toolkit=3Dathena --without-toolkit-scroll-bars --without-ns --with-xft --without-dbus --without-gconf --without-gsettings --with-zlib --prefix=3D/usr --sysconfdir=3D/etc --sbindir=3D/usr/bin --bindir=3D/usr/bin --mandir=3D/usr/share/man --infodir=3D/usr/share/info --localstatedir=3D/var --host=3Dx86_64-unknown-linux-gnu --build=3Dx86_64-unknown-linux-gnu '--libdir=3D${exec_prefix}/lib64' --with-file-notification=3Dinotify --with-modules --with-native-compilation --with-jpeg --with-tiff --with-gif --with-png --with-xpm --with-rsvg --with-imagemagick --with-json --with-xml2 --with-gnutls --with-sound --with-m17n-flt --with-harfbuzz --with-cairo --with-lcms --without-gmp 'CFLAGS=3D-fno-PIE -mtune=3Dgeneric -O2 -pipe ' 'CPPFLAGS=3D ' 'LDFLAGS=3D-no-pie -Wl,--as-needed '' Configured features: ACL CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ IMAGEMAGICK JPEG JSON LCMS2 LIBOTF LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF X11 XDBE XIM XPM LUCID ZLIB Important settings: value of $LC_ALL: en_GB.UTF-8 value of $LC_COLLATE: en_GB.UTF-8 value of $LC_CTYPE: en_GB.UTF-8 value of $LANG: en_GB.UTF-8 value of $XMODIFIERS: @im=3Dibus locale-coding-system: utf-8-unix Memory information: ((conses 16 677156 287115) (symbols 48 39801 7) (strings 32 181641 67878) (string-bytes 1 6097769) (vectors 16 66337) (vector-slots 8 1256518 570753) (floats 8 909 1141) (intervals 56 1260 531) (buffers 992 22))