From: Alejandro Colomar <alx@kernel.org>
To: Deri <deri@chuzzlewit.myzen.co.uk>
Cc: linux-man@vger.kernel.org, groff@gnu.org
Subject: Re: Optimize script for generating LinuxManBook.pdf
Date: Fri, 24 Nov 2023 12:46:30 +0100 [thread overview]
Message-ID: <ZWCNHM9qQnK96ksZ@debian> (raw)
In-Reply-To: <ZV_OXhw7V6Vk1HBR@debian>
[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]
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
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-11-24 11:46 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 [this message]
2023-11-30 16:56 ` Deri
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=ZWCNHM9qQnK96ksZ@debian \
--to=alx@kernel.org \
--cc=deri@chuzzlewit.myzen.co.uk \
--cc=groff@gnu.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