Hi Marc,

Marc Espie wrote on Mon, Sep 04, 2023 at 12:11:52AM +0200:
> On Sun, Sep 03, 2023 at 08:54:55PM +0200, Ingo Schwarze wrote:

>> In addition to that, showing the complete list from man -w would
>> force man(1) to do additional work, slowing down display of the
>> manual page.  When any of the -w, -a, or -k options is given, man(1)
>> always searches through the whole MANPATH.  By contrast, in standard
>> mode, i.e. without any of these three options, it ends the search
>> after the first database that returns a match and displays that
>> match right away.  For example, if you type "man printf", only the
>> base system manual page database is inspected and you do not have to

> How much work is that actually ?  I mean with the current database system
> if you just say "man something" it ought to be fairly quick, no ?
> 
> (especially with just 3 databases)

Actually, you have a point here.  On my notebook, measuring the
difference isn't even trivial.  I managed to do it by inserting calls to
  clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...)
into the code.  On my notebook, the variation of the times is quite
large while the times themselves are rather small, but anyway,
here are the results for a simple name lookup, not including times
for reading, parsing, and formatting the actual manual page file -
all times in milliseconds:

  program startup time until the program reaches main(): 2 - 4 ms
  prep work before opening the database (option parsing etc.): 0.4 - 0.6 ms
  lookup time in the base system database: 1 - 3 ms
  lookup time in the Xenocara database: 0.5 - 1.5 ms
  lookup time in the ports database: 0.9 - 2.3 ms

It looks like the difference is measureable.  I performed no rigorous
statistics, but a crude estimate might be that skipping the Xenocara
and ports databases as we currently do saves about half the lookup
time, or in absolute terms about 2 milliseconds on average on my
notebook.

Frankly, i don't have a luna88k machine, but at least on modern
hardware, it looks like this doesn't matter at all.

So *if* we want to show this information to the user, i guess i could
just take that micro-optimization out and always scan all databases.

However, nobody told me so far that they like the idea of showing this
information, but one developer told me privately that they are not a fan.

By the way, the point of getting rid of that optimization would be
that in a situation like this,

   $ man -w FvwmPager
  /usr/X11R6/man/man1/FvwmPager.1
  /usr/local/man/man1/FvwmPager.1

we would get, with the patch and without the optimization,

   $ man FvwmPager
  Showing:  /usr/X11R6/man/man1/FvwmPager.1
  See also: /usr/local/man/man1/FvwmPager.1

  FvwmPager(1)           General Commands Manual          FvwmPager(1)

  NAME
       FvwmPager - the FVWM Pager module
  [...]

That looks neat for the FVWM case - however, i fear some people might
like exactly the same feature less in this case:

   $ man ls
  Showing:  /usr/share/man/man1/ls.1
  See also: /usr/local/man/man1/gls.1

  LS(1)                  General Commands Manual                 LS(1)

  NAME
     ls - list directory contents
  [...]


So, if many people use neither -w nor -a, how do you usually find out
that there are multiple manual pages for the name you are looking for?
Are you using

  man -f printf     # but i would have expected that to be even less known?
  man -k Nm=printf  # but that can be quite noisy IMHO...

Or?

Yours,
  Ingo

Reply via email to