Re: Optimize script for generating LinuxManBook.pdf

2023-11-23 Thread Deri
On Wednesday, 22 November 2023 14:58:56 GMT Alejandro Colomar wrote:
> Hi Deri,
> 
> I've optimized from 18.5 s down to 16.3 s the script, by splitting the
> pipeline with this wrapper (and slightly reducing the perl script to
> just print the pages to stdout).  BTW, now it can be run from any
> directory.  And every step can be debugged by just introducing
> 
> | tee /dev/tty \
> 
> wherever you want to debug.  It's all pushed to master.
> 
> The PDF is now printed to stdout, to avoid hard-coding file names.
> 
> I still need to split a bit more and reduce the longest lines.  How does
> this script look to you?
> 
> Cheers,
> Alex :-)
> 

Hi Alex,

It looks fine, although you have to run the code in 
"prepare_linux_man_book.pl" twice (to avoid using a temporary file). If you 
are going to run preconv it is best to run it first - stops pic spitting out 
loads of warnings. You also dropped one stage in second pass, no pic in the 
pipeline. This may explain part of the speedup you observed. I don't know if 
any of your man pages require pic but they could in the future. The changes I 
would advise are:-

--- a/scripts/LinuxManBook/build_linux_man_book.sh
+++ b/scripts/LinuxManBook/build_linux_man_book.sh
@@ -4,8 +4,8 @@
 
 (
"$(dirname "$0")"/prepare_linux_man_book.pl "$1" \
-   | pic \
| preconv \
+   | pic \
| tbl \
| eqn -Tpdf \
| troff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 -dpaper=a4 \
@@ -16,6 +16,7 @@
"$(dirname "$0")"/prepare_linux_man_book.pl "$1";
 ) \
 | preconv \
+| pic \
 | tbl \
 | eqn -Tpdf \
 | (

Cheers

Deri






Re: Optimize script for generating LinuxManBook.pdf

2023-11-23 Thread Alejandro Colomar
Hi Deri,

On Thu, Nov 23, 2023 at 06:41:14PM +, Deri wrote:
> Hi Alex,
> 
> It looks fine, although you have to run the code in 
> "prepare_linux_man_book.pl" twice (to avoid using a temporary file).

Yep.  I was wondering if we could change something in the design of
prepare_linux_man_book.pl so that it could be run once without needing
a temporary file.  Maybe if it could insert something in the pages that
the latter troff(1) would process in one take, without having to put all
the bookmarks at the start of the file.  That would be an important
simplification of the scripts, and probably also an optimization.

> If you 
> are going to run preconv it is best to run it first - stops pic spitting out 
> loads of warnings.

Thanks!  Makes sense.

> You also dropped one stage in second pass, no pic in the 
> pipeline. This may explain part of the speedup you observed. I don't know if 
> any of your man pages require pic but they could in the future. The changes I 
> would advise are:-

Thanks!  I've applied those changes; will push in a moment.  The speedup
is still the same; probably because pic(1)'s throughput is faster than
the consumers of its output, and its latency is negligible.  Since it
doesn't slow down, I've added it, just in case we want to use pic(1) in
some page in the future, as you say.

Cheers,
Alex

> 
> --- a/scripts/LinuxManBook/build_linux_man_book.sh
> +++ b/scripts/LinuxManBook/build_linux_man_book.sh
> @@ -4,8 +4,8 @@
>  
>  (
> "$(dirname "$0")"/prepare_linux_man_book.pl "$1" \
> -   | pic \
> | preconv \
> +   | pic \
> | tbl \
> | eqn -Tpdf \
> | troff -Tpdf -dPDF.EXPORT=1 -dLABEL.REFS=1 -dpaper=a4 \
> @@ -16,6 +16,7 @@
> "$(dirname "$0")"/prepare_linux_man_book.pl "$1";
>  ) \
>  | preconv \
> +| pic \
>  | tbl \
>  | eqn -Tpdf \
>  | (
> 
> Cheers
> 
> Deri
> 
> 
> 
> 

-- 



signature.asc
Description: PGP signature