From: Deri <deri@chuzzlewit.myzen.co.uk>
To: Alejandro Colomar <alx@kernel.org>
Cc: linux-man@vger.kernel.org
Subject: Re: Optimize script for generating LinuxManBook.pdf
Date: Thu, 30 Nov 2023 16:56:38 +0000 [thread overview]
Message-ID: <17198161.Vt6cx1TxTY@pip> (raw)
In-Reply-To: <ZWCNHM9qQnK96ksZ@debian>
[-- Attachment #1: Type: text/plain, Size: 2321 bytes --]
On Friday, 24 November 2023 11:46:30 GMT Alejandro Colomar wrote:
> On Thu, Nov 23, 2023 at 11:12:45PM +0100, Alejandro Colomar wrote:
> > > 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.
>
> Hi Deri,
>
> I have another optimization: split the sort. It reduces around 0.3 s.
>
> diff --git a/scripts/LinuxManBook/prepare_linux_man_book.pl
> b/scripts/LinuxManBook/prepare_linux_man_book.pl index 0a79df4e5..5a4aad429
> 100755
> --- a/scripts/LinuxManBook/prepare_linux_man_book.pl
> +++ b/scripts/LinuxManBook/prepare_linux_man_book.pl
> @@ -88,7 +88,16 @@ sub BuildBook
> {
> print ".pdfpagenumbering D . 1\n";
>
> - foreach my $fn (sort sortman glob("$dir/man*/*")) {
> + foreach my $fn (sort glob("$dir/man*")) {
> + BuildSec($fn);
> + }
> +}
> +
> +sub BuildSec
> +{
> + my $manSdir=shift;
> +
> + foreach my $fn (sort sortman glob("$manSdir/*")) {
> BuildPage($fn);
> }
> }
>
>
> I didn't think of this as an optimization, but rather to move code from
> BuildPage() into BuildSec(). However, since it doesn't block until all
> of the pages are sorted, it reduces the latency of the script (that's my
> guess).
>
> I think moving stuff from BuildPage() to BuildSec() would both simplify
> and optimize, so please check it when you can. (I'm also checking it,
> but while I'm learning Perl with this, I'm still very limited.)
>
> Cheers,
> Alex
Hi Alex,
I have attached the latest iteration of my work, managed to knock two seconds
off the current code in your git. It no longer uses temporary files, outputs
the pdf to stdout, can be run from any directory and runs groff once.
It replaces the complete LinuxManBook directory and the executable is now
called BuildLinuxMan2.pl.
Cheers
Deri
[-- Attachment #2: LinuxManBook.tgz --]
[-- Type: application/x-compressed-tar, Size: 371754 bytes --]
next prev parent reply other threads:[~2023-11-30 16:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 14:58 Optimize script for generating LinuxManBook.pdf Alejandro Colomar
2023-11-22 17:33 ` Deri
2023-11-22 17:39 ` Alejandro Colomar
2023-11-23 18:41 ` Deri
2023-11-23 22:12 ` Alejandro Colomar
2023-11-24 11:46 ` Alejandro Colomar
2023-11-30 16:56 ` Deri [this message]
2023-11-30 22:38 ` Alejandro Colomar
2023-12-01 0:14 ` Alejandro Colomar
2023-12-01 0:37 ` Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17198161.Vt6cx1TxTY@pip \
--to=deri@chuzzlewit.myzen.co.uk \
--cc=alx@kernel.org \
--cc=linux-man@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox