This begun with me seeing that my emacs man-mode
was suspiciously slow, and I found that emacs was invoking man -k ^
and man -k^[number]
on the command-line whenever I type M-x man RET [number]
. The timing and wc output is kind of ridiculous:
% time man -k ^ | wc
makewhatis: /Library/TeX/texbin/man: Not a directory
12434 101864 923700
man -k ^ 0.67s user 1.40s system 103% cpu 1.991 total
wc 0.01s user 0.02s system 1% cpu 1.990 total
Why is it that the total time is nearly 2 seconds when it seems the operation took about ~0.03 seconds? I believe this may be what is causing a severe slowdown, and I'd like to get to the bottom of this bloat in my system. MacOS Ventura.
You need to understand what you are looking at.
man -k ^3
will search the entire man
database for every manual page whose abstract begins with 3
(there are none). man -k ^
will simply output all abstracts. This is a moderately expensive operation, especially if man
needs to rebuild its indices behind the scenes. However, the main part of the processing is in waiting for the disk while reading and possibly writing the indices, and buffering the output it writes, so it does not consume a lot of CPU in the end.
Your time
output for wc
obviously only accounts for the time it took to process the output from man
, which is trivial.
You are apparently using Zsh, which does not include the "real" time in the time
output. On my system, after running man -k ^
repeatedly, the entire process takes on the order of 10 seconds, but out of that, it only consumes about 5s of CPU time (0.8s user + 4s system).
Ultimately, we have to ask why you enter a number after M-x man
and what you hope to accomplish eventually. If you really want a list of all installed man pages, or all man pages in a particular section, it is going to take a while.
(On my system, M-x man <RET> 3 <RET>
only outputs some internal junk which looks like man
internal shell scripts, reformatted.)