GNU bug report logs - #35562
"varset" bytecode inline path is never taken

Previous Next

Package: emacs;

Reported by: Simon Frankau <sgf <at> arbitrary.name>

Date: Sat, 4 May 2019 15:37:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35562 in the body.
You can then email your comments to 35562 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#35562; Package emacs. (Sat, 04 May 2019 15:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Simon Frankau <sgf <at> arbitrary.name>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 04 May 2019 15:37:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simon Frankau <sgf <at> arbitrary.name>
To: bug-gnu-emacs <at> gnu.org
Subject: "varset" bytecode inline path is never taken
Date: Sat, 4 May 2019 14:27:23 +0100
[Message part 1 (text/plain, inline)]
While reading the source, I noticed in bytecode.c that:

    /* Inline the most common case.  */
    if (SYMBOLP (sym)
&& !EQ (val, Qunbound)
&& *!XSYMBOL (sym)->u.s.redirect*
&& !SYMBOL_TRAPPED_WRITE_P (sym))
      SET_SYMBOL_VAL (XSYMBOL (sym), val);

should be:

    /* Inline the most common case.  */
    if (SYMBOLP (sym)
&& !EQ (val, Qunbound)
&& *XSYMBOL (sym)->u.s.redirect == SYMBOL_PLAINVAL*
&& !SYMBOL_TRAPPED_WRITE_P (sym))
      SET_SYMBOL_VAL (XSYMBOL (sym), val);

As it is, the inline case is never run, since "redirect" is always non-zero.

Since I'm new to emacs internals, I don't know how to benchmark to work out
if this makes a noticable performance difference. :)

Thanks,
Simon.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35562; Package emacs. (Sat, 04 May 2019 16:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 35562 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Simon Frankau <sgf <at> arbitrary.name>
Cc: 35562 <at> debbugs.gnu.org
Subject: Re: bug#35562: "varset" bytecode inline path is never taken
Date: Sat, 04 May 2019 12:10:12 -0400
Simon Frankau <sgf <at> arbitrary.name> writes:

> While reading the source, I noticed in bytecode.c that:

> && *!XSYMBOL (sym)->u.s.redirect*

> should be:

> && *XSYMBOL (sym)->u.s.redirect == SYMBOL_PLAINVAL*

> As it is, the inline case is never run, since "redirect" is always non-zero.
>
> Since I'm new to emacs internals, I don't know how to benchmark to work out
> if this makes a noticable performance difference. :)

I guess something like this might work (haven't tested to see if
difference is measurable though):

    (defvar bug-35562-test-var nil)
    (benchmark-run-compiled
        (dotimes (_ 1000000)
          ;; Unroll a bit, so that setting `bug-35562-test-var' takes more
          ;; time than incrementing loop counter.
          (setq bug-35562-test-var nil)
          (setq bug-35562-test-var nil)
          (setq bug-35562-test-var nil)
          (setq bug-35562-test-var nil)
          (setq bug-35562-test-var nil)
          (setq bug-35562-test-var nil)
          (setq bug-35562-test-var nil)
          (setq bug-35562-test-var nil)))




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sat, 04 May 2019 18:17:01 GMT) Full text and rfc822 format available.

Notification sent to Simon Frankau <sgf <at> arbitrary.name>:
bug acknowledged by developer. (Sat, 04 May 2019 18:17:02 GMT) Full text and rfc822 format available.

Message #13 received at 35562-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Simon Frankau <sgf <at> arbitrary.name>
Cc: 35562-done <at> debbugs.gnu.org
Subject: "varset" bytecode inline path is never taken
Date: Sat, 4 May 2019 11:16:23 -0700
Thanks for reporting that typo. I verified that the patch improves performance 
significantly (50% speedup) on Noam's benchmark, and installed the patch into 
the Emacs master branch.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 Jun 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 323 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.