Package: apt-mirror
Severity: wishlist
Tags: patch
apt-mirror stat(2)'s all files found in Packages/Sources. Many of them
are stat(2)'ed many times, because Packages/Sources may point to the
same file (especially in testing/unstable).
Provided patch caches stat(2) results, and it greatly improves speed
of Packages/Sources.
This patch also has been sent upstream.
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (800, 'testing'), (700, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/dash
Kernel: Linux 2.6.17-2-686
Locale: LANG=C, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
--- apt-mirror-0.4.4/apt-mirror 2006-09-13 21:22:32.000000000 +0700
+++ apt-mirror 2006-09-13 21:22:27.000000000 +0700
@@ -330,11 +330,25 @@
open FILES_NEW, ">" . get_variable("var_path") . "/NEW" or die("apt-mirror:
can't write to intermediate file (NEW)");
open FILES_MD5, ">" . get_variable("var_path") . "/MD5" or die("apt-mirror:
can't write to intermediate file (MD5)");
+my %stat_cache = ();
+
+sub _stat {
+ my ($filename) = shift;
+ return @{$stat_cache{$filename}} if exists $stat_cache{$filename};
+ my @res = stat($filename);
+ $stat_cache{$filename} = [EMAIL PROTECTED];
+ return @res;
+}
+
+sub clear_stat_cache {
+ %stat_cache = ();
+}
+
sub need_update {
my $filename = shift;
my $size_on_server = shift;
- my (undef, undef, undef, undef, undef, undef, undef, $size) =
stat($filename);
+ my (undef, undef, undef, undef, undef, undef, undef, $size) =
_stat($filename);
return 1 unless($size);
return 0 if $size_on_server == $size;
@@ -430,6 +444,8 @@
}
}
+clear_stat_cache();
+
print "]\n\n";
close FILES_ALL;