unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, mattiase@acm.org, gregory@heytings.org,
	monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: Time to merge scratch/correct-warning-pos into master, perhaps?
Date: Fri, 25 Feb 2022 22:29:01 +0000	[thread overview]
Message-ID: <YhlYLfG5VzUA6J5F@ACM> (raw)
In-Reply-To: <831qzyzt5t.fsf@gnu.org>

Hello, Eli.

On Sat, Feb 19, 2022 at 19:02:22 +0200, Eli Zaretskii wrote:
> > Date: Sat, 19 Feb 2022 16:42:07 +0000
> > Cc: gregory@heytings.org, monnier@iro.umontreal.ca, mattiase@acm.org,
> >   larsi@gnus.org, emacs-devel@gnu.org
> > From: Alan Mackenzie <acm@muc.de>
> > 
> > I haven't got any useful information out of the exercise, so far.  I
> > can't help feeling that I'm missing something.  Is there anything I ought
> > to be doing that I've not yet done?

> Maybe you should make EQ real function, with an attribute that would
> preclude its inlining.

> I have no other ideas.  Maybe someone else does.

I now have some numbers.

I've compared the versions of the master branch just before and just
after the merge of scratch/correct-warning-pos with this difference in
the new version:
(i) A binding of load-read-function was removed (this should be
  irrelevant).

, and this difference in the old version:
(i) The macro/function BASE_EQ was copied from the new version and NILP
  amended to use it.  This excludes NILP from contributing to the EQ
  measurements in the old version, just as it is in the new.

In both versions, the inlining was removed from EQ, which was then
inserted into xdisp.c as a normal function which invokes the macro
lisp_h_EQ.  This macro differs between the old and new versions.

These two versions were configured the same, without native-compilation,
and built.  A make check was run to compile (most of) the test-foo.elc
files.  Then in each the following were run:

    $ perf record -e cpu-clock make check
    $ perf report -i perf.data --tui

..  The proportions of the profiler samples in EQ were:
   (old): 0.48%
   (new): 0.86%

..  This is fairly close to the guessed factor of 2 difference.  However,
it doesn't, by itself, account for the difference in total run time
between the two versions.  The total number of events counted for these
make check runs was
  (old): 372k
  (new): 419k

..  The breakdown of samples on individual instructions in the old and new
versions of EQ is thus:

(old):
EQ  /home/acm/emacs/emacs.git/sub-master-b/src/emacs [Percent: local period]
Samples│
       │
       │
       │   Disassembly of section .text:
       │
       │   0000000000071550 <EQ>:
       │   EQ():
       │
       │   /* STOUGH, 2022-02-19 */
       │   bool
       │   EQ (Lisp_Object x, Lisp_Object y)
       │   {
       │   return lisp_h_EQ (x, y);
   946 │     cmp  %rdi,%rsi
   172 │     sete %al
       │   }
   675 │   ← ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(new):
EQ  /home/acm/emacs/emacs.git/sub-master-2/src/emacs [Percent: local period]
Samples│
       │
       │
       │    Disassembly of section .text:
       │
       │    000000000006d150 <EQ>:
       │    EQ():
       │    no-ops.  */
       │
       │    INLINE EMACS_INT
       │    (XLI) (Lisp_Object o)
       │    {
       │    return lisp_h_XLI (o);
  1230 │      mov    $0x1,%eax
       │
       │    /* STOUGH, 2022-02-19 */
       │    bool
       │    EQ (Lisp_Object x, Lisp_Object y)
       │    {
       │    return lisp_h_EQ (x, y);
   311 │      cmp    %rsi,%rdi
   617 │    ↓ je     76
       │      movzbl globals+0xfee,%eax
  1340 │      test   %al,%al
    81 │    ↓ je     76
       │    TAGGEDP():
       │    Equivalent to XTYPE (a) == TAG, but often faster.  */
       │
       │    INLINE bool
       │    (TAGGEDP) (Lisp_Object a, enum Lisp_Type tag)
       │    {
       │    return lisp_h_TAGGEDP (a, tag);
       │      lea    -0x5(%rdi),%eax
       │    PSEUDOVECTORP():
       │    #define MOST_NEGATIVE_FIXNUM (-1 - MOST_POSITIVE_FIXNUM)
       │
       │    INLINE bool
       │    PSEUDOVECTORP (Lisp_Object a, int code)
       │    {
       │    return lisp_h_PSEUDOVECTORP (a, code);
     5 │      test   $0x7,%al
     9 │    ↓ jne    50
       │      movabs $0x400000003f000000,%rdx
       │      mov    -0x5(%rdi),%rcx
     1 │      movabs $0x4000000006000000,%rax
       │      and    %rdx,%rcx
       │      cmp    %rax,%rcx
       │    ↓ jne    50
       │    EQ():
       │      test   $0x7,%sil
       │    ↓ jne    90
       │      cmp    %rsi,0x3(%rdi)
       │      sete   %al
       │    ← ret
       │      nop
       │    TAGGEDP():
       │    return lisp_h_TAGGEDP (a, tag);
       │50:   lea    -0x5(%rsi),%eax
       │    PSEUDOVECTORP():
       │    return lisp_h_PSEUDOVECTORP (a, code);
     4 │      test   $0x7,%al
     5 │    ↓ jne    74
       │      movabs $0x400000003f000000,%rax
       │      and    -0x5(%rsi),%rax
     1 │      movabs $0x4000000006000000,%rdx
       │      cmp    %rdx,%rax
       │    ↓ je     80
       │74:   xor    %eax,%eax
       │    EQ():
       │    }
     1 │76: ← ret
       │      nop
       │    return lisp_h_EQ (x, y);
       │80:   test   $0x7,%dil
       │    ↑ jne    74
       │      cmp    %rdi,0x3(%rsi)
       │      sete   %al
       │    ← ret
       │      xchg   %ax,%ax
       │    TAGGEDP():
       │    return lisp_h_TAGGEDP (a, tag);
       │90:   lea    -0x5(%rsi),%r8d
       │    PSEUDOVECTORP():
       │      xor    %eax,%eax
       │    return lisp_h_PSEUDOVECTORP (a, code);
       │      and    $0x7,%r8d
       │    ↑ jne    76
       │      and    -0x5(%rsi),%rdx
       │      cmp    %rcx,%rdx
       │    ↑ jne    76
       │    EQ():
       │      mov    0x3(%rdi),%rax
       │      cmp    %rax,0x3(%rsi)
       │      sete   %al
       │    ← ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

As yet, I don't know quite what to make of these numbers.

-- 
Alan Mackenzie (Nuremberg, Germany).



  parent reply	other threads:[~2022-02-25 22:29 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-15 18:15 Time to merge scratch/correct-warning-pos into master, perhaps? Alan Mackenzie
2022-01-15 18:24 ` Eli Zaretskii
2022-01-16  8:24   ` Lars Ingebrigtsen
2022-01-16  9:51     ` Po Lu
2022-01-16 13:50       ` Alan Mackenzie
2022-01-16 12:02     ` Lars Ingebrigtsen
2022-01-16 12:06       ` Po Lu
2022-01-16 13:12         ` Lars Ingebrigtsen
2022-01-16 14:02           ` Alan Mackenzie
2022-01-17  0:28           ` Po Lu
2022-01-17  3:28             ` Eli Zaretskii
2022-01-17  3:37               ` Po Lu
2022-01-16 14:00         ` Alan Mackenzie
2022-01-16 12:23       ` Eli Zaretskii
2022-01-16 12:26         ` Lars Ingebrigtsen
2022-01-16 12:36           ` Eli Zaretskii
2022-01-16 14:06         ` Alan Mackenzie
2022-01-16 14:11           ` Lars Ingebrigtsen
2022-01-16 14:21           ` Eli Zaretskii
2022-01-16 14:45             ` Alan Mackenzie
2022-01-16 15:04               ` Eli Zaretskii
2022-01-16 15:26                 ` Alan Mackenzie
2022-01-16 15:43                   ` Eli Zaretskii
2022-01-16 15:50                     ` Alan Mackenzie
2022-01-16 13:47     ` Alan Mackenzie
2022-01-16 14:10       ` Lars Ingebrigtsen
2022-01-16 14:59         ` Stefan Monnier
2022-01-16 14:57     ` Stefan Monnier
2022-01-16 15:04       ` Lars Ingebrigtsen
2022-01-16 15:37         ` Alan Mackenzie
2022-01-16 15:50         ` Mattias Engdegård
2022-01-16 16:18           ` Alan Mackenzie
2022-01-16 16:52             ` Mattias Engdegård
2022-01-16 17:13               ` Stefan Monnier
2022-01-16 17:24                 ` Mattias Engdegård
2022-01-22 12:23         ` Alan Mackenzie
2022-01-22 14:30           ` Lars Ingebrigtsen
2022-01-22 15:09             ` Alan Mackenzie
2022-01-22 15:26               ` Lars Ingebrigtsen
2022-01-22 15:36                 ` Eli Zaretskii
2022-01-22 18:30                   ` Alan Mackenzie
2022-01-23 12:45                     ` Lars Ingebrigtsen
2022-01-22 16:06             ` Mattias Engdegård
2022-01-22 17:02               ` Gregory Heytings
2022-01-22 17:46                 ` Eli Zaretskii
2022-01-22 18:01                   ` Gregory Heytings
2022-01-22 18:12                     ` Eli Zaretskii
2022-01-22 22:36                       ` Gregory Heytings
2022-01-22 22:55                         ` Alan Mackenzie
2022-01-23  6:16                         ` Eli Zaretskii
2022-01-23 21:53                           ` Gregory Heytings
2022-01-24  3:37                             ` Eli Zaretskii
2022-01-24 15:20                               ` Gregory Heytings
2022-01-24 16:47                                 ` Eli Zaretskii
2022-01-24 20:41                                   ` Gregory Heytings
2022-01-25  3:34                                     ` Eli Zaretskii
2022-01-25  8:59                                       ` Gregory Heytings
2022-01-25 11:27                                         ` Alan Mackenzie
2022-01-25 13:27                                           ` Stefan Monnier
2022-01-25 18:27                                             ` Alan Mackenzie
2022-01-25 19:26                                               ` Stefan Monnier
2022-01-25 20:58                                                 ` Alan Mackenzie
2022-01-25 21:27                                                   ` Gregory Heytings
2022-01-26 17:32                                                     ` Alan Mackenzie
2022-01-26 18:59                                                       ` Gregory Heytings
2022-01-26 20:26                                                         ` Alan Mackenzie
2022-01-25 22:11                                                   ` Stefan Monnier
2022-01-25 22:42                                                     ` Óscar Fuentes
2022-01-26  1:08                                                       ` Po Lu
2022-01-26 16:56                                                         ` chad
2022-01-26 17:38                                                           ` Eli Zaretskii
2022-01-26 17:58                                                             ` chad
2022-01-26 18:46                                                         ` Gregory Heytings
2022-01-26 19:47                                                           ` Stefan Monnier
2022-01-26 19:59                                                           ` Alan Mackenzie
2022-01-25 21:18                                                 ` Gregory Heytings
2022-01-25 21:38                                             ` Gregory Heytings
2022-01-25 22:21                                               ` Stefan Monnier
2022-01-26 18:36                                                 ` Gregory Heytings
2022-02-04  0:11                                                 ` Gregory Heytings
2022-02-04 11:57                                                   ` Alan Mackenzie
2022-02-04 12:06                                                     ` Eli Zaretskii
2022-02-04 18:31                                                       ` Alan Mackenzie
2022-02-04 18:54                                                         ` Eli Zaretskii
2022-02-04 19:33                                                           ` Alan Mackenzie
2022-02-04 19:46                                                             ` Eli Zaretskii
2022-02-04 21:24                                                               ` Alan Mackenzie
2022-02-04 22:24                                                                 ` Stefan Monnier
2022-02-04 22:30                                                                   ` Stefan Monnier
2022-02-05  7:28                                                                     ` Eli Zaretskii
2022-02-05 18:04                                                                       ` Stefan Monnier
2022-02-05 18:31                                                                         ` Eli Zaretskii
2022-02-05  8:17                                                                 ` Eli Zaretskii
2022-02-06 11:50                                                                   ` Alan Mackenzie
2022-02-06 11:56                                                                     ` Eli Zaretskii
2022-02-06 18:09                                                                       ` Alan Mackenzie
2022-02-06 18:39                                                                         ` Eli Zaretskii
2022-02-19 16:42                                                                           ` Alan Mackenzie
2022-02-19 17:02                                                                             ` Eli Zaretskii
2022-02-19 17:43                                                                               ` David Engster
2022-02-19 22:10                                                                                 ` Alan Mackenzie
2022-02-20  5:35                                                                                   ` David Engster
2022-02-20 19:45                                                                                     ` Alan Mackenzie
2022-02-20 20:37                                                                                   ` Stefan Monnier
2022-02-20 20:56                                                                                     ` Alan Mackenzie
2022-02-20 23:02                                                                                       ` Stefan Monnier
2022-02-21  0:22                                                                                         ` Óscar Fuentes
2022-02-21  3:31                                                                                           ` Eli Zaretskii
2022-02-21  4:04                                                                                             ` Óscar Fuentes
2022-02-21 12:15                                                                                               ` Eli Zaretskii
2022-02-21 14:55                                                                                                 ` Óscar Fuentes
2022-02-21  3:29                                                                                         ` Eli Zaretskii
2022-02-19 19:01                                                                               ` Stefan Monnier
2022-02-19 19:30                                                                                 ` Eli Zaretskii
2022-02-19 22:03                                                                               ` Alan Mackenzie
2022-02-25 22:29                                                                               ` Alan Mackenzie [this message]
2022-02-06 18:40                                                                         ` Eli Zaretskii
2022-02-06 19:03                                                                           ` Eli Zaretskii
2022-02-07 17:36                                                                             ` Andrea Corallo
2022-02-05  6:08                                                   ` Lars Ingebrigtsen
2022-02-05 11:42                                                     ` Alan Mackenzie
2022-02-05 21:31                                                       ` Lars Ingebrigtsen
2022-02-06  7:02                                                         ` Eli Zaretskii
2022-02-06 11:38                                                         ` Alan Mackenzie
2022-02-06 23:14                                                           ` Lars Ingebrigtsen
2022-01-25 21:15                                           ` Gregory Heytings
2022-01-25 21:30                                             ` Andrea Corallo
2022-01-26 18:43                                               ` Gregory Heytings
2022-01-26 21:04                                                 ` Andrea Corallo
     [not found]                                           ` <b0265c41-7ead-4913-667-d0e76a35b3ba@heytings.org>
2022-01-25 21:16                                             ` Gregory Heytings
2022-01-25 12:26                                         ` Eli Zaretskii
2022-01-26 18:41                                           ` Gregory Heytings
2022-01-26 18:59                                             ` Eli Zaretskii
2022-01-26 19:14                                               ` Stefan Monnier
2022-01-26 19:32                                                 ` Eli Zaretskii
2022-01-26 19:34                                             ` Alan Mackenzie
2022-01-22 18:35                 ` Alan Mackenzie
2022-01-22 18:45                   ` Gregory Heytings
2022-01-22 18:50                     ` Eli Zaretskii
2022-01-22 20:07                       ` Gregory Heytings
2022-01-23  5:32                         ` Eli Zaretskii
2022-01-23 21:44                           ` Gregory Heytings
2022-01-15 22:57 ` Stefan Monnier
2022-01-16  0:27 ` Brahimi Saifullah
2022-01-16 14:53   ` Alan Mackenzie
2022-01-16 16:45     ` Brahimi Saifullah
2022-01-22 11:41       ` Alan Mackenzie
2022-01-22 23:16         ` Brahimi Saifullah
2022-01-23 14:09           ` Alan Mackenzie
2022-01-17  9:38 ` Andrea Corallo

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=YhlYLfG5VzUA6J5F@ACM \
    --to=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=gregory@heytings.org \
    --cc=larsi@gnus.org \
    --cc=mattiase@acm.org \
    --cc=monnier@iro.umontreal.ca \
    /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).