Subject: Re: bug#18522: 24.4.50; mapcar is very slow

From: Peter Münster <[email-masked]>
Date: Sun, 21 Feb 2016 12:00:07 +0100

On Sat, Feb 20 2016, Eli Zaretskii wrote:

> I'd start with profiler.el, to profile the Lisp portions of the
> function.  It's probably best to load the .el file first and profile
> that, although this could skew the profile (because the byte-compiled
> version behaves differently).

Here are 2 profiler reports. The first one, where parse-time-string is
very slow:

--8<---------------cut here---------------start------------->8---
- command-execute                                                8396  93%
 - call-interactively                                            8396  93%
  - funcall-interactively                                        7881  88%
   - eval-expression                                             7848  87%
    - eval                                                       7848  87%
     - let                                                       7848  87%
      - while                                                    7848  87%
       - parse-time-string                                       7840  87%
        - let                                                    7836  87%
         - parse-time-tokenize                                   7089  79%
          - let                                                  7073  79%
           - while                                               7057  78%
            - while                                              6959  77%
             - and                                               6891  77%
              - setq                                             4445  49%
               - parse-time-string-chars                         4413  49%
                - let                                            4301  48%
                 - unwind-protect                                4189  46%
                  - progn                                        4141  46%
                   - let                                          436   4%
                    - cond                                        408   4%
                     - string-match                                96   1%
                        setq                                       68   0%
                    set-match-data                                  4   0%
              - not                                              2338  26%
               - setq                                            2310  25%
                - parse-time-string-chars                        2282  25%
                 - let                                           2258  25%
                  - unwind-protect                               2170  24%
                   - progn                                       2126  23%
                    - let                                         176   1%
                     - cond                                       160   1%
                      - string-match                               24   0%
                         setq                                      16   0%
--8<---------------cut here---------------end--------------->8---

And this one from "emacs -Q":

--8<---------------cut here---------------start------------->8---
- command-execute                                                2643  90%
 - call-interactively                                            2643  90%
  - funcall-interactively                                        2221  75%
   - eval-expression                                             2013  68%
    - eval                                                       2013  68%
     - let                                                       2013  68%
      - while                                                    2013  68%
       - parse-time-string                                       2002  68%
        - let                                                    2002  68%
         - parse-time-tokenize                                   1291  44%
          - let                                                  1283  43%
           - while                                               1272  43%
            - while                                              1112  38%
             - and                                               1044  35%
              - setq                                              640  21%
               - parse-time-string-chars                          608  20%
                - let                                             557  19%
                 - unwind-protect                                 461  15%
                  - progn                                         401  13%
                   - let                                          345  11%
                    - cond                                        285   9%
                     - string-match                                56   1%
                        setq                                       40   1%
                    set-match-data                                 16   0%
              - not                                               288   9%
               - setq                                             268   9%
                - parse-time-string-chars                         244   8%
                 - let                                            208   7%
                  - unwind-protect                                192   6%
                   - progn                                        152   5%
                    - let                                         120   4%
                     - cond                                       112   3%
                      - string-match                               32   1%
                         setq                                      32   1%
                     set-match-data                                 4   0%
--8<---------------cut here---------------end--------------->8---

It seems to me, that there is a problem with "progn":

Slow emacs:
                  - progn                                        4141  46%
                   - let                                          436   4%

Fast emacs:
                  - progn                                         401  13%
                   - let                                          345  11%

What do you think?

-- 
           Peter