bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#48734: 28.0.50; Performance regression in `string-width`?


From: Imran Khan
Subject: bug#48734: 28.0.50; Performance regression in `string-width`?
Date: Mon, 31 May 2021 18:36:40 +0600

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Eli Zaretskii <eliz@gnu.org> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]