Subject: Re: bug#35562: "varset" bytecode inline path is never taken

From: Noam Postavsky <[email-masked]>
Date: Sat, 04 May 2019 12:10:12 -0400

Simon Frankau <[email-masked]> 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)))