Ingo Schwarze wrote (2023-09-04 01:42 IST):
> 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

Does it work for you like this? Because here it doesn't. It works for
printf, but for FvwmPager / FvwmButtons, no alternatives are displayed.

We should probably only display results from the same section. For other
sections, the "SEE ALSO" part of the manpage is sufficient. This would 
also lead to the "feature" not run that often. Most of the time "man 
<thing>" should just show the manpage.

For insanity reasons, I installed all autoconfs:

$ man 1 autoconf
 Showing:  /usr/local/man/man1/autoconf-2.52.1
 See also: /usr/local/man/man1/autoconf-2.54.1
 See also: /usr/local/man/man1/autoconf-2.56.1
 See also: /usr/local/man/man1/autoconf-2.57.1
 See also: /usr/local/man/man1/autoconf-2.58.1
 See also: /usr/local/man/man1/autoconf-2.59.1
 See also: /usr/local/man/man1/autoconf-2.60.1
 See also: /usr/local/man/man1/autoconf-2.61.1
 See also: /usr/local/man/man1/autoconf-2.62.1
 See also: /usr/local/man/man1/autoconf-2.63.1
 See also: /usr/local/man/man1/autoconf-2.64.1
 See also: /usr/local/man/man1/autoconf-2.65.1
 See also: /usr/local/man/man1/autoconf-2.67.1
 See also: /usr/local/man/man1/autoconf-2.68.1
 See also: /usr/local/man/man1/autoconf-2.69.1
 See also: /usr/local/man/man1/autoconf-2.71.1

 AUTOCONF(1)                           FSF                          AUTOCONF(1)
...

Is this too much at the top of the man page?

It should also be excluded for non-interactive use. Some web frontends
do "man $thing | text2html > $thing.html"

How about:

$ man 1 autoconf
 There is more than one version of this manpage available (show with -w).

 AUTOCONF(1)                           FSF                          AUTOCONF(1)
...

Then you could stop after the second match in the same section.

Best regards,
Stefan

Reply via email to