user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 1/2] manifest.js.gz: avoid long-lived per-epoch cat-file processes
  2021-09-11 23:30  5% [PATCH 0/2] www: per-inbox manifest.js.gz improvements Eric Wong
@ 2021-09-11 23:30  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-09-11 23:30 UTC (permalink / raw)
  To: meta

When generating per-inbox manifests, we were forgetting to
cleanup per-epoch "git cat-file --batch" processes.  Our
previous method of generating modified times was also stupidly
inefficient, so replace the pipeline with a single
"git for-each-ref" invocation.
---
 lib/PublicInbox/Git.pm          | 25 +++++--------------------
 lib/PublicInbox/ManifestJsGz.pm |  2 +-
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index e557f6d6..219a1732 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -16,7 +16,7 @@ use Errno qw(EINTR EAGAIN);
 use File::Glob qw(bsd_glob GLOB_NOSORT);
 use File::Spec ();
 use Time::HiRes qw(stat);
-use PublicInbox::Spawn qw(popen_rd);
+use PublicInbox::Spawn qw(popen_rd spawn);
 use PublicInbox::Tmpfile;
 use IO::Poll qw(POLLIN);
 use Carp qw(croak);
@@ -466,28 +466,13 @@ sub cat_async ($$$;$) {
 	push(@$inflight, $oid, $cb, $arg);
 }
 
-sub extract_cmt_time {
-	my ($bref, undef, undef, undef, $modified) = @_;
-
-	if ($$bref =~ /^committer .*?> ([0-9]+) [\+\-]?[0-9]+/sm) {
-		my $cmt_time = $1 + 0;
-		$$modified = $cmt_time if $cmt_time > $$modified;
-	}
-}
-
 # returns the modified time of a git repo, same as the "modified" field
 # of a grokmirror manifest
 sub modified ($) {
-	my ($self) = @_;
-	my $modified = 0;
-	my $fh = popen($self, qw(rev-parse --branches));
-	local $/ = "\n";
-	while (my $oid = <$fh>) {
-		chomp $oid;
-		cat_async($self, $oid, \&extract_cmt_time, \$modified);
-	}
-	cat_async_wait($self);
-	$modified || time;
+	# committerdate:unix is git 2.9.4+ (2017-05-05), so using raw instead
+	my $fh = popen($_[0], qw[for-each-ref --sort=-committerdate
+				--format=%(committerdate:raw) --count=1]);
+	(split(/ /, <$fh> // time))[0] + 0; # integerize for JSON
 }
 
 # for grokmirror, which doesn't read gitweb.description
diff --git a/lib/PublicInbox/ManifestJsGz.pm b/lib/PublicInbox/ManifestJsGz.pm
index 69d81fa1..cde60245 100644
--- a/lib/PublicInbox/ManifestJsGz.pm
+++ b/lib/PublicInbox/ManifestJsGz.pm
@@ -27,7 +27,7 @@ sub inject_entry ($$$;$) {
 	$ctx->{manifest}->{$url_path} = $ent;
 }
 
-sub manifest_add ($$;$$) { # slow path w/o extindex "all"
+sub manifest_add ($$;$$) { # slow path w/o extindex "all" (or per-inbox)
 	my ($ctx, $ibx, $epoch, $default_desc) = @_;
 	my $url_path = "/$ibx->{name}";
 	my $git;

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/2] www: per-inbox manifest.js.gz improvements
@ 2021-09-11 23:30  5% Eric Wong
  2021-09-11 23:30  7% ` [PATCH 1/2] manifest.js.gz: avoid long-lived per-epoch cat-file processes Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-09-11 23:30 UTC (permalink / raw)
  To: meta

Speed things up for people wanting to clone a single inbox and
significantly reduce server overheads.  [1/2] should be
noticeable to -httpd admins if users are cloning single inboxes.

Eric Wong (2):
  manifest.js.gz: avoid long-lived per-epoch cat-file processes
  www: use ->ALL for per-inbox manifest.js.gz, too

 lib/PublicInbox/Git.pm          | 25 +++++--------------------
 lib/PublicInbox/ManifestJsGz.pm | 16 ++++++++--------
 t/extindex-psgi.t               | 20 ++++++++++++++++++--
 3 files changed, 31 insertions(+), 30 deletions(-)

^ permalink raw reply	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-09-11 23:30  5% [PATCH 0/2] www: per-inbox manifest.js.gz improvements Eric Wong
2021-09-11 23:30  7% ` [PATCH 1/2] manifest.js.gz: avoid long-lived per-epoch cat-file processes Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).