Package: dwww Version: 1.13.3+b1 Severity: normal Tags: patch Hi,
presumably to keep a machine's load low during indexing, dwww-index++ sleeps 0.15s before feeding the next file to index to index++. During the generation of live-images, a huge amount of time is just wasted when running dwww-index++ from a hook script. The attached patch allows for configuration of the sleep time via dwww.conf. For my build system (the build root residing on a tmpfs) and live-image package list, this reduces the execution time of dwww-index++ from ~40min to 20s. \o/ The second patch solves a problem I stumbled upon while I created the first one: any config variable containing a value that evaluates to boolean false in a ternary expression would get ignored, its hard-coded default value taking effect instead. The patch changes the check to rely on defined($var) instead of the variable's specific content. Cheers Daniel
>From 3406a2866a209f2686bb123723c813e29fd3a3b9 Mon Sep 17 00:00:00 2001 From: Daniel Reichelt <deb...@nachtgeist.net> Date: Wed, 8 Nov 2017 18:25:20 +0100 Subject: [PATCH 2/2] Allow for config values which evaluate to boolean false Setting e.g. DWWW_INDEX_FULL_SLEEP_TIME to 0 would be evaluated to false and thus cause the corresponding default value from $cfgvars to be used. This changes the check to not rely on the specific contents of variables and to check whether they are defined instead. --- perl/Debian/Dwww/Initialize.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl/Debian/Dwww/Initialize.pm b/perl/Debian/Dwww/Initialize.pm index 9c633ed..114784e 100644 --- a/perl/Debian/Dwww/Initialize.pm +++ b/perl/Debian/Dwww/Initialize.pm @@ -18,7 +18,7 @@ sub DwwwInitialize($) { my $cfgvars = ReadConfigFile($filename); my $dwwwvars = {}; - map +{ $dwwwvars->{$_} = $cfgvars->{$_}->{'cfgval'} ? $cfgvars->{$_}->{'cfgval'} + map +{ $dwwwvars->{$_} = defined($cfgvars->{$_}->{'cfgval'}) ? $cfgvars->{$_}->{'cfgval'} : $cfgvars->{$_}->{'defval'} }, keys %$cfgvars; umask (022); -- 2.14.2
>From 406a428249f71fed8ed1228360846373f2e4a76b Mon Sep 17 00:00:00 2001 From: Daniel Reichelt <deb...@nachtgeist.net> Date: Wed, 8 Nov 2017 18:25:20 +0100 Subject: [PATCH 1/2] dwww-index++: make sleep time after each file configurable --- man/dwww.7 | 8 ++++++++ perl/Debian/Dwww/ConfigFile.pm | 5 +++++ scripts/dwww-index++ | 6 +++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/man/dwww.7 b/man/dwww.7 index 68d066a..8b6962b 100644 --- a/man/dwww.7 +++ b/man/dwww.7 @@ -230,6 +230,14 @@ If this variable is set to .BR dwww\-index++ (8) will generate index of registered documentation. .\" +.IP DWWW_INDEX_FULL_SLEEP_TIME +In order to not impede regular server operation, +.BR dwww\-index++ (8) +sleeps for the specified amount of time (in seconds) before feeding the next file path to index to +.BR index++ (1). +The default value is +.BR 0.15 . +.\" .IP DWWW_INDEX_FULL_TIME_INTERVAL Specifies how often (in days) .BR dwww\-index++ (8) diff --git a/perl/Debian/Dwww/ConfigFile.pm b/perl/Debian/Dwww/ConfigFile.pm index 664180f..c75cd51 100644 --- a/perl/Debian/Dwww/ConfigFile.pm +++ b/perl/Debian/Dwww/ConfigFile.pm @@ -96,6 +96,11 @@ sub ReadConfigFile($) { defval => 28, descr => 'How often (in days) dwww-index++(8) will generate full index of documentation.' }, + 'DWWW_INDEX_FULL_SLEEP_TIME' => { + sort => 50, + defval => 0.15, + descr => 'How long (in seconds) dwww-index++ should sleep after each file in order to not impact regular server operation.' + }, 'DWWW_INDEX_INCREMENTAL_TIME_INTERVAL' => { sort => 50, defval => 7, diff --git a/scripts/dwww-index++ b/scripts/dwww-index++ index 59e3ab1..1e49350 100755 --- a/scripts/dwww-index++ +++ b/scripts/dwww-index++ @@ -218,9 +218,9 @@ sub WriteListOfFilesToIndex($$ ) { # {{{ my $do_sleep = shift; foreach my $f (sort keys %new_files_hash) { - syswrite $FH, "$new_files_hash{$f}\n"; - # sleep 150 ms - select(undef, undef, undef, 0.15) if $do_sleep; + syswrite $FH, "$new_files_hash{$f}\n"; + # sleep the configured amount of time, if $do_sleep + select(undef, undef, undef, $dwwwconf->{'DWWW_INDEX_FULL_SLEEP_TIME'}) if $do_sleep; } } # }}} -- 2.14.2