unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: Aaron Jensen <aaronjensen@gmail.com>
Cc: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>, emacs-devel@gnu.org
Subject: Re: macOS metal rendering engine in mac port
Date: Fri, 21 May 2021 18:39:08 +0100	[thread overview]
Message-ID: <YKfwPETnQGSbkMq3@breton.holly.idiocy.org> (raw)
In-Reply-To: <CAHyO48xmAi91WyXadiXePBvjoBzYy=Kr=UCxWUt87tp9qCm+wQ@mail.gmail.com>

On Fri, May 21, 2021 at 08:27:14AM -0700, Aaron Jensen wrote:
> On Fri, May 21, 2021 at 12:35 AM Alan Third <alan@idiocy.org> wrote:
> >
> > Out of interest, is it the metal renderer making the difference, or is
> > the Mac port just better anyway?
> >
> > I only ask because on my Mac enabling metal rendering results in a
> > *much* lower frame rate (although whether that equates to higher input
> > lag I don't know).

Thanks for this.

> Pressing and holding a key for 10s with a high key repeat rate:
> 
> Large frame:
> 
> NS: 300 letters input
> Macport: 530 letters input
> Macport with metal: 515 letters input

That is quite a dramatic difference!

> So yes, it appears that the macport without metal is actually faster
> on my machine which is surprising.

I believe this is why it's no longer the default. All the shouting was
when it was disabled and people didn't read the note and thought it
was new.

> How do you typically measure framerate?

With this code that I nabbed from in here:

     (defun scroll-up-benchmark ()
       (interactive)
       (let ((oldgc gcs-done)
             (oldtime (float-time)))
         (condition-case nil (while t (scroll-up) (redisplay))
           (error (message "GCs: %d Elapsed time: %f seconds"
                           (- gcs-done oldgc) (- (float-time) oldtime))))))

> That said, I have an app on my phone called "Is it snappy" that uses
> the high speed camera to attempt to measure input latency. With my
> full config measuring the input latency I get:
> 
> Large frame:
> 
> NS: 95.8 100.0 107.9 (101.2 ms avg)
> Macport: 100.0 95.4 95.8 (97.1 ms avg)
> Macport with Metal: 78.7 87.5 99.6 (88.6 ms avg)

This is quite interesting! It looks like metal reduces the total
throughput, but speeds up the time it take to actually get the image
to the screen. I wonder why that is...?

> > What might be helpful is to profile to find out what's slowing the NS
> > port down.
> 
> Can I profile with XCode? What debug optimization level do I have to
> use to make it useful?

Yes, and I don't think you need to do anything special with
optimisation levels.

Load instruments.app, choose "time profiler", then at the top select
emacs and hit the record button. Do whatever you do, then hit the stop
button, and the window below should give some indication of where it
is spending the most time. I was thinking that it would be in the copy
from one surface to the other, but I profiled my own build and it
appears to be negligible. OTOH, since your surfaces are much bigger
that might be it.

I've tried reducing the amount of times the NS port updates the
screen, although I don't think I've really been very successful, but
you may as well give it a go and see if it makes any difference.
Please try the scratch/ns/surface-stuff branch.

And for a laugh try this patch on top of that branch. It's not
suitable for general use, but it seems a bit faster here.

modified   src/nsterm.m
@@ -8516,6 +8516,7 @@ - (void)updateLayer
      could use to force it, but we shouldn't often get the same
      surface twice in a row.  */
   [[self layer] setContents:(id)[surface getSurface]];
+  [[self layer] setContentsChanged];
 }
 #endif
 
@@ -9716,7 +9717,7 @@ @implementation EmacsSurface
    probably be some sort of pruning job that removes excess
    surfaces.  */
 
-#define CACHE_MAX_SIZE 2
+#define CACHE_MAX_SIZE 1
 
 - (id) initWithSize: (NSSize)s
          ColorSpace: (CGColorSpaceRef)cs

If that doesn't help with the lag then I think I've only got one other
thing to try before trying to implement 3D rendering. ;)
-- 
Alan Third



  reply	other threads:[~2021-05-21 17:39 UTC|newest]

Thread overview: 155+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  1:17 macOS metal rendering engine in mac port Aaron Jensen
2021-05-21  6:07 ` Eli Zaretskii
2021-05-21  6:13   ` Aaron Jensen
2021-05-21  7:35 ` Alan Third
2021-05-21 15:27   ` Aaron Jensen
2021-05-21 17:39     ` Alan Third [this message]
     [not found]       ` <CAHyO48ys2sYxbZuho1NutqNAM-z0tTaKwuR1TxUuhMZG5XJ0aA@mail.gmail.com>
2021-05-22 16:01         ` Aaron Jensen
2021-05-22 16:30           ` Eli Zaretskii
2021-05-22 16:46             ` Eli Zaretskii
2021-05-22 17:00               ` Eli Zaretskii
2021-05-22 18:44         ` Alan Third
2021-05-22 18:59           ` Aaron Jensen
2021-05-22 19:57             ` Alan Third
2021-05-22 21:20               ` Aaron Jensen
2021-05-23 11:47                 ` Alan Third
2021-05-23 16:09                   ` Stefan Monnier
2021-05-23 16:13                   ` Aaron Jensen
2021-05-23 17:06                     ` Aaron Jensen
2021-05-23 17:21                       ` Eli Zaretskii
2021-05-23 18:38                         ` Aaron Jensen
2021-05-23 18:48                           ` Eli Zaretskii
2021-05-23 19:49                             ` Aaron Jensen
2021-05-24  0:00                           ` Aaron Jensen
2021-05-24  0:04                             ` Aaron Jensen
     [not found]                               ` <CAHyO48z1m5aeqwqmZds3yuYiJ=rdHZ79JPVyuh1kHVU0Rw47EA@mail.gmail.com>
2021-05-24  6:51                                 ` Aaron Jensen
2021-05-24  7:37                                   ` Eli Zaretskii
2021-05-24  8:07                                     ` Aaron Jensen
2021-05-24  8:48                                       ` Eli Zaretskii
2021-05-24 15:32                                         ` Aaron Jensen
2021-05-24 16:28                                           ` Eli Zaretskii
2021-05-24 16:31                                             ` Aaron Jensen
2021-05-24 16:43                                               ` Eli Zaretskii
2021-05-24 17:58                                                 ` Aaron Jensen
2021-05-24 18:03                                                   ` Eli Zaretskii
2021-05-24 18:16                                                     ` Alan Third
2021-05-24 18:18                                                     ` Aaron Jensen
2021-05-24 18:54                                                       ` Eli Zaretskii
2021-05-24 19:07                                                         ` Aaron Jensen
2021-05-24 19:21                                                           ` Eli Zaretskii
2021-05-24 19:27                                                             ` Eli Zaretskii
2021-05-24 20:21                                                               ` Aaron Jensen
2021-05-25  2:31                                                                 ` Eli Zaretskii
     [not found]                                                                   ` <CAHyO48yxxdURvZSzrWn-F+6wKwHgpwcoXD7_w0NmWLcfBKkUkw@mail.gmail.com>
2021-05-25  5:41                                                                     ` Eli Zaretskii
2021-05-25  6:26                                                                       ` Aaron Jensen
2021-05-25 12:16                                                                         ` Eli Zaretskii
2021-05-25 12:23                                                                           ` Alan Third
2021-05-25 12:56                                                                           ` Alan Third
2021-05-25 13:00                                                                             ` Eli Zaretskii
2021-05-25 13:07                                                                               ` Alan Third
2021-05-25 13:18                                                                                 ` Eli Zaretskii
2021-05-25 13:34                                                                                   ` Alan Third
2021-05-25 13:47                                                                                     ` Eli Zaretskii
2021-05-25 13:50                                                                                       ` Alan Third
2021-05-27 16:55                                                                             ` Eli Zaretskii
2021-05-27 17:40                                                                               ` Alan Third
2021-05-27 17:47                                                                                 ` Eli Zaretskii
2021-05-27 17:51                                                                                   ` Alan Third
2021-05-27 17:53                                                                                     ` Aaron Jensen
2021-05-27 18:59                                                                                       ` Eli Zaretskii
2021-05-27 19:02                                                                                         ` Aaron Jensen
2021-05-27 19:22                                                                                           ` Eli Zaretskii
2021-05-27 19:37                                                                                             ` Aaron Jensen
2021-05-28 17:58                                                                                               ` Eli Zaretskii
2021-05-28 18:21                                                                                                 ` Aaron Jensen
2021-05-28 19:00                                                                                                   ` Eli Zaretskii
2021-05-25 15:35                                                                           ` Aaron Jensen
2021-05-25 17:34                                                                             ` Eli Zaretskii
2021-05-25 17:48                                                                               ` Aaron Jensen
2021-05-25  9:01                                                                     ` Alan Third
2021-05-24 12:47                                 ` Eli Zaretskii
2021-05-24 16:10                                   ` Aaron Jensen
2021-05-23 21:20                       ` Alan Third
2021-05-23 22:04                         ` Alan Third
2021-05-23 22:12                           ` Alan Third
2021-05-23 21:08                     ` Alan Third
2021-05-23 22:37                       ` Aaron Jensen
2021-05-24  9:01                         ` Alan Third
2021-05-25 16:31                           ` Aaron Jensen
2021-05-26  0:32                             ` Aaron Jensen
2021-05-26  6:23                               ` Alan Third
2021-05-26  6:26                                 ` Aaron Jensen
2021-05-26  7:35                                   ` Aaron Jensen
2021-05-28 17:39                                 ` Aaron Jensen
2021-05-28 18:32                                   ` Alan Third
2021-05-28 19:00                                     ` Aaron Jensen
2021-05-28 19:29                                       ` Alan Third
2021-05-28 22:07                                         ` Aaron Jensen
2021-05-29  6:07                                           ` Eli Zaretskii
2021-05-29  7:01                                             ` Aaron Jensen
2021-05-29  7:05                                               ` Eli Zaretskii
2021-05-29  8:52                                                 ` Aaron Jensen
2021-05-29  9:06                                                   ` Aaron Jensen
2021-05-29  9:21                                                     ` Eli Zaretskii
2021-05-29  9:35                                                       ` Alan Third
2021-05-29  9:41                                                         ` Eli Zaretskii
2021-05-29 16:18                                                         ` Aaron Jensen
2021-05-29 16:49                                                           ` Eli Zaretskii
2021-05-29 17:05                                                             ` Aaron Jensen
2021-05-29 17:20                                                               ` Aaron Jensen
2021-05-29 17:43                                                                 ` Eli Zaretskii
2021-05-29 18:00                                                                   ` Dmitry Gutov
2021-05-29 18:15                                                                     ` Eli Zaretskii
2021-05-29 18:52                                                                       ` Dmitry Gutov
2021-05-29 19:06                                                                       ` Stefan Monnier
2021-05-29 19:10                                                                         ` Eli Zaretskii
2021-05-29 17:34                                                               ` Eli Zaretskii
2021-05-29 18:22                                                                 ` Aaron Jensen
2021-05-29 18:27                                                                   ` Aaron Jensen
2021-05-29 18:40                                                                   ` Eli Zaretskii
2021-05-29 19:30                                                                     ` Aaron Jensen
2021-05-29 20:03                                                                       ` Eli Zaretskii
2021-05-29 21:03                                                                         ` Aaron Jensen
2021-05-29 21:05                                                                           ` Aaron Jensen
2021-05-29 21:40                                                                             ` Aaron Jensen
2021-05-30  4:44                                                                               ` Aaron Jensen
2021-05-30  7:01                                                                                 ` Eli Zaretskii
2021-05-30  6:27                                                                               ` Eli Zaretskii
2021-05-30  7:04                                                                                 ` Aaron Jensen
2021-05-30  9:36                                                                                   ` Eli Zaretskii
2021-05-30 15:46                                                                                     ` Aaron Jensen
2021-05-30 16:03                                                                                       ` Eli Zaretskii
2021-05-30 16:16                                                                                         ` Aaron Jensen
2021-05-30 16:35                                                                                           ` Eli Zaretskii
2021-05-30 17:00                                                                                             ` Aaron Jensen
2021-05-30 17:18                                                                                               ` Eli Zaretskii
2021-05-30 23:59                                                                                                 ` Aaron Jensen
2021-05-31  2:28                                                                                                   ` Eli Zaretskii
2021-05-31  2:30                                                                                                     ` Aaron Jensen
2021-06-03 21:42                                                                                                       ` Alan Third
2021-06-03 21:43                                                                                                         ` Aaron Jensen
2021-09-15 13:16                                                                                                         ` Aaron Jensen
2021-09-15 19:30                                                                                                           ` Illia Ostapyshyn
2021-09-15 19:54                                                                                                             ` Alan Third
2021-09-16 15:59                                                                                                               ` Y. E. via Emacs development discussions.
2021-09-17 17:31                                                                                                                 ` Alan Third
2021-09-17 17:43                                                                                                                   ` Aaron Jensen
2021-09-18  5:42                                                                                                                   ` Y. E. via Emacs development discussions.
2021-09-20 21:22                                                                                                                   ` Illia Ostapyshyn
2021-09-21  7:22                                                                                                                     ` Y. E. via Emacs development discussions.
2021-09-21 18:48                                                                                                                       ` Alan Third
2021-09-27 10:07                                                                                                                         ` Alan Third
2021-10-04 14:58                                                                                                                           ` Aaron Jensen
2021-10-25 19:39                                                                                                                           ` Illia Ostapyshyn
2021-10-26 12:16                                                                                                                             ` Alan Third
2021-10-26 13:26                                                                                                                               ` Aaron Jensen
2021-09-16 10:01                                                                                                           ` Rudolf Adamkovič
2021-05-30  6:22                                                                           ` Eli Zaretskii
2021-05-29  9:12                                                   ` Alan Third
2021-05-29  9:26                                                     ` Eli Zaretskii
2021-05-29  9:32                                                       ` Alan Third
2021-05-29  9:37                                                         ` Eli Zaretskii
2021-05-29  9:39                                                           ` Eli Zaretskii
2021-05-29  9:44                                                             ` Alan Third
2021-05-29 14:12                                                             ` Alan Third
2021-05-23 23:32                       ` Tim Cross

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=YKfwPETnQGSbkMq3@breton.holly.idiocy.org \
    --to=alan@idiocy.org \
    --cc=aaronjensen@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=mituharu@math.s.chiba-u.ac.jp \
    /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).