unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
To: Eli Zaretskii <eliz-mXXj517/zsQ@public.gmane.org>
Cc: 14966-ubl+/3LiMTaZdePnXv/OxA@public.gmane.org
Subject: bug#14966: 24.3.50; Char-displayable-p is a very long running function
Date: Mon, 29 Jul 2013 10:18:26 +0200	[thread overview]
Message-ID: <8661vt6ap9.fsf@somewhere.org> (raw)
In-Reply-To: <mailman.1910.1374927252.12400.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org> (Eli Zaretskii's message of "Sat, 27 Jul 2013 13:49:08 +0300")

Eli Zaretskii wrote:
>> From: "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
>> Date: Sat, 27 Jul 2013 11:47:30 +0200
>> 
>> When looking at the performance of my .emacs at startup time, I've noticed
>> that (char-displayable-p) takes around 400 ms (!) to execute itself...
>
> It calls the font driver to actually encode the character.  That could
> look up several fonts.  FWIW, I see 219 ms on my i7 Windows desktop.

FWIW, I can't reproduce it in a minimal Emacs file (and I remember that the
tests were, in fact, done on my wife's laptop, a recent i5).

Minimal Emacs file:

--8<---------------cut here---------------start------------->8---
(defconst em/emacs-load-time-start (float-time))

;; set default font for all frames
;; (modify-all-frames-parameters '((font . "Consolas-10")))              ;; 0.58 s (max 2.13 s on battery)
;; (modify-all-frames-parameters '((font . "Courier New-9")))            ;; 0.58 s (max 2.13 s on battery)
;; (modify-all-frames-parameters '((font . "DejaVu Sans Mono-9")))       ;; 0.07 s (max 0.25 s on battery)
;; (modify-all-frames-parameters '((font . "Lucida Sans Typewriter-9"))) ;; 0.13 s (max 0.48 s on battery)
;; (modify-all-frames-parameters '((font . "Lucida Console-9")))         ;; 0.57 s (max 2.09 s on battery)
;; default (i.e., nothing)                                               ;; 0.58 s (max 1.83 s on battery)

(defadvice message (before leuven-when-was-that activate)
  "Add timestamps to `message' output."
  (ad-set-arg 0 (concat (format-time-string "[%Y-%m-%d %T.")
                        (substring (format-time-string "%N") 0 3)
                        (format-time-string "] ")
                        (ad-get-arg 0))))

(dolist (i '(1 2 3 4 5 6 7 8 9 10))

  (setq org-ellipsis
         (if (char-displayable-p ?\u25B7) ;; white right-pointing triangle
             " \u25B7" ;; string
           'org-ellipsis))

  (message "Call nr %s" i))

(message "Loading Minimal Emacs... Done (in %.2f s)"
         (- (float-time) em/emacs-load-time-start))
--8<---------------cut here---------------end--------------->8---

Notice that the time spent depends a lot on the chosen font!!!  It is quite
constant (at 0.01 s diff when on mains) for one specific font. For another
font, it can be more than 8 x the time (from 0.07 to 0.58 s).

FWIW, I don't understand the timing in the *Messages* buffer:

--8<---------------cut here---------------start------------->8---
For information about GNU Emacs and the GNU system, type C-h C-a.
[2013-07-29 10:08:14.866] Call nr 1
[2013-07-29 10:08:14.869] Call nr 2
[2013-07-29 10:08:14.870] Call nr 3
[2013-07-29 10:08:14.870] Call nr 4
[2013-07-29 10:08:14.871] Call nr 5
[2013-07-29 10:08:14.872] Call nr 6
[2013-07-29 10:08:14.872] Call nr 7
[2013-07-29 10:08:14.873] Call nr 8
[2013-07-29 10:08:14.873] Call nr 9
[2013-07-29 10:08:14.874] Call nr 10
[2013-07-29 10:08:14.874] Loading Minimal Emacs... Done (in 0.58 s)
--8<---------------cut here---------------end--------------->8---

14.874 (after last call) - 14.866 (after first call) is 0.008 s, not really
0.580 s!???

Something really escapes me here.

> Unless char-displayable-p is called in an inner loop (is it?), this
> shouldn't really matter, should it?

I'm not sure to understand this sentence. What do you mean by inner loop?
As I said to Andreas, I'm looking (hard) to get a startup time of Emacs under
the second. So, for that purpose, yes, it does matter. Though, in general, it
certainly does not hurt that much.

Best regards,
  Seb

-- 
Sebastien Vauban





  parent reply	other threads:[~2013-07-29  8:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-27  9:47 bug#14966: 24.3.50; Char-displayable-p is a very long running function Sebastien Vauban
2013-07-27 10:49 ` Eli Zaretskii
2013-07-27 11:59 ` Andreas Schwab
2013-07-27 14:21 ` Stefan Monnier
     [not found] ` <mailman.1908.1374926410.12400.bug-gnu-emacs@gnu.org>
2013-07-29  8:10   ` Sebastien Vauban
2013-07-29 16:24     ` Eli Zaretskii
2020-11-18 15:24       ` Stefan Kangas
2020-11-18 17:13         ` Eli Zaretskii
2020-11-18 18:29           ` Stefan Kangas
     [not found] ` <mailman.1910.1374927252.12400.bug-gnu-emacs@gnu.org>
     [not found]   ` <mailman.1910.1374927252.12400.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-07-29  8:18     ` Sebastien Vauban [this message]
     [not found] ` <mailman.1923.1374934927.12400.bug-gnu-emacs@gnu.org>
     [not found]   ` <mailman.1923.1374934927.12400.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-07-29  8:19     ` Sebastien Vauban

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8661vt6ap9.fsf@somewhere.org \
    --to=sva-news-d0wtavr13harg/idocfnwg@public.gmane.org \
    --cc=14966-ubl+/3LiMTaZdePnXv/OxA@public.gmane.org \
    --cc=eliz-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).