protesilaos / mct

Enhancements for the default minibuffer completion UI of Emacs.
https://protesilaos.com/emacs/mct
GNU General Public License v3.0
33 stars 3 forks source link

`M-x man` has a noticable delay #8

Open zenspider opened 1 month ago

zenspider commented 1 month ago

man isn't the only one... but it is one of the more obvious ones... I've even added it to the blocklist.

I don't quite know how to get timings on an interactive to measure whether this is mct or maybe something's happened to my system to make man that much slower...

protesilaos commented 1 month ago

From: Ryan Davis @.***> Date: Tue, 16 Jul 2024 11:16:20 -0700

man isn't the only one... but it is one of the more obvious ones... I've even added it to the blocklist.

Maybe it is slow in general for whatever reason? Can you disable 'mct-mode' and try again?

I don't quite know how to get timings on an interactive to measure whether this is mct or maybe something's happened to my system to make man that much slower...

Have you tried the profiler? The idea is that you start it, do what you need to measure, and then produce the report. Then you check the resulting buffer to see where Emacs spends most of its resources.

Steps:

-- Protesilaos Stavrou https://protesilaos.com

zenspider commented 1 month ago

Not sure I did this quite right... it's gotta have some wallclock delays because it is an interactive command, but here's what I got that is relevant:

         281  93% - command-execute
         281  93%  - call-interactively
         143  47%   - byte-code
         143  47%    - read-extended-command
         143  47%     - read-extended-command-1
         143  47%      - completing-read
         143  47%       - completing-read-default
         143  47%        - apply
         143  47%         + mct--completing-read-advice
         138  46%   - funcall-interactively
         138  46%    - execute-extended-command
         137  45%     - command-execute
         137  45%      - call-interactively
         130  43%       - byte-code
         130  43%        - completing-read
         130  43%         - completing-read-default
         130  43%          - apply
         130  43%           - mct--completing-read-advice
         130  43%            + apply
           7   2%       + funcall-interactively
          12   4% + Man-bgproc-filter
           3   1% + redisplay_internal (C function)
           3   1% + Man-bgproc-sentinel
           0   0% + ...

no manpath env to speak of... OS is mac os.

and here it is without mct:

         144  94% - command-execute
         144  94%  - call-interactively
         105  69%   - byte-code
         105  69%    - read-extended-command
         105  69%     - read-extended-command-1
         105  69%      - completing-read
         105  69%       + completing-read-default
          39  25%   - funcall-interactively
          39  25%    - execute-extended-command
          39  25%     - command-execute
          39  25%      - call-interactively
          37  24%       - byte-code
          36  23%        + completing-read
           1   0%        + format-prompt
           2   1%       + funcall-interactively
           6   3% + timer-event-handler
           2   1% + redisplay_internal (C function)
           0   0% + ...
zenspider commented 1 month ago

Trying to remove human delay:

(progn
  (profiler-start 'cpu)
  (call-interactively #'man)
  (profiler-stop)
  (profiler-report))
         183 100% - command-execute
         183 100%  - call-interactively
         183 100%   - funcall-interactively
         182  99%    - eval-last-sexp
         182  99%     - elisp--eval-last-sexp
         182  99%      - eval
         182  99%       - progn
         180  98%        - call-interactively
         165  90%         - byte-code
         165  90%          - completing-read
         165  90%           - completing-read-default
         165  90%            - apply
         165  90%             - mct--completing-read-advice
         165  90%              - apply
         165  90%               - #<compiled -0x5e6a2c561523167>
          75  40%                + read-from-minibuffer
           4   2%         - funcall-interactively
           4   2%          - man
           4   2%           + Man-getpage-in-background
           2   1%         + interactive-form
           2   1%          profiler-stop
           1   0%    + minibuffer-complete
           0   0% + ...

unfortunately it goes from mct at 90% of time to read-from-minibuffer at 40% with roughly nothing shown in between.

zenspider commented 1 month ago

reversed calltree (hit B) might help more:

          24  24% - #<compiled -0x5eebec902c83167>
          24  24%  - apply
          24  24%   - mct--completing-read-advice
          24  24%    - apply
          24  24%     - completing-read-default
          24  24%      + completing-read
          17  17% + Man-parse-man-k
          16  16% + Man-completion-table