* [PATCH 0/3] reduce synchronous waitpid calls
@ 2024-05-30 9:45 Eric Wong
2024-05-30 9:45 ` [PATCH 1/3] gcf2: eliminate unnecessary autodie::close import Eric Wong
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2024-05-30 9:45 UTC (permalink / raw)
To: meta
1/3 is just something I noticed while preparing for 2/3.
2/3 removes the synchronous PublicInbox::IO::close calls
in favor of PublicInbox::IO::DESTROY.
3/3 means fewer spawns, so fewer waits.
There's still the ->object_format call from SolverGit
that needs to be dealt with, but that's more involved...
Eric Wong (3):
gcf2: eliminate unnecessary autodie::close import
git: prefer WNOHANG for `git cat-file --batch-*'
git: reduce spawning for rev-parse --git-path
lib/PublicInbox/Gcf2.pm | 2 +-
lib/PublicInbox/Git.pm | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] gcf2: eliminate unnecessary autodie::close import
2024-05-30 9:45 [PATCH 0/3] reduce synchronous waitpid calls Eric Wong
@ 2024-05-30 9:45 ` Eric Wong
2024-05-30 9:45 ` [PATCH 2/3] git: prefer WNOHANG for `git cat-file --batch-*' Eric Wong
2024-05-30 9:45 ` [PATCH 3/3] git: reduce spawning for rev-parse --git-path Eric Wong
2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-05-30 9:45 UTC (permalink / raw)
To: meta
We no longer call close() in Gcf2. I noticed this since I plan
on eliminating some needless ->close calls in PublicInbox::Git.
---
lib/PublicInbox/Gcf2.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/PublicInbox/Gcf2.pm b/lib/PublicInbox/Gcf2.pm
index 78392990..acc2091c 100644
--- a/lib/PublicInbox/Gcf2.pm
+++ b/lib/PublicInbox/Gcf2.pm
@@ -11,7 +11,7 @@ use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
use IO::Handle; # autoflush
use PublicInbox::Git qw($ck_unlinked_packs);
use PublicInbox::Lock;
-use autodie qw(close open seek truncate);
+use autodie qw(open seek truncate);
BEGIN {
my (%CFG, $c_src);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] git: prefer WNOHANG for `git cat-file --batch-*'
2024-05-30 9:45 [PATCH 0/3] reduce synchronous waitpid calls Eric Wong
2024-05-30 9:45 ` [PATCH 1/3] gcf2: eliminate unnecessary autodie::close import Eric Wong
@ 2024-05-30 9:45 ` Eric Wong
2024-05-30 9:45 ` [PATCH 3/3] git: reduce spawning for rev-parse --git-path Eric Wong
2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-05-30 9:45 UTC (permalink / raw)
To: meta
When inside our DS event loop, ensure we don't stall on
synchronous waitpid when stopping `--batch-*' processes.
Instead of calling PublicInbox::IO::close explicitly, let
refcounting close the socket via PublicInbox::IO::DESTROY and
the SIGCHLD handler will deal with it when the kernel and event
loop get to it.
---
lib/PublicInbox/Git.pm | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index ff38efa1..55005475 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -208,7 +208,7 @@ sub cat_async_retry ($$) {
$oid = \$oid if !@$new_inflight; # to indicate oid retried
push @$new_inflight, $oid, $cb, $arg;
}
- $sock->close if $sock; # only safe once old_inflight is empty
+ undef $sock; # gcf_drain may run from PublicInbox::IO::DESTROY
cat_async_step($self, $new_inflight); # take one step
}
@@ -665,10 +665,9 @@ sub watch_async ($) {
sub close {
my ($self) = @_;
- my $sock = $self->{sock};
delete @$self{qw(-bc err_c inflight)};
delete($self->{epwatch}) ? $self->SUPER::close : delete($self->{sock});
- $sock->close if $sock; # calls gcf_drain via awaitpid
+ # gcf_drain may run from PublicInbox::IO::DESTROY
}
package PublicInbox::GitCheck; # only for git <2.36
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] git: reduce spawning for rev-parse --git-path
2024-05-30 9:45 [PATCH 0/3] reduce synchronous waitpid calls Eric Wong
2024-05-30 9:45 ` [PATCH 1/3] gcf2: eliminate unnecessary autodie::close import Eric Wong
2024-05-30 9:45 ` [PATCH 2/3] git: prefer WNOHANG for `git cat-file --batch-*' Eric Wong
@ 2024-05-30 9:45 ` Eric Wong
2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2024-05-30 9:45 UTC (permalink / raw)
To: meta
Since every non-worktree git repo has an `objects' directory, we
can quickly stat(2) to check for its presence and avoid an
expensive process spawn. This should be the common case on
servers since it's rare to use worktrees on servers for
coderepos (or inboxes).
---
lib/PublicInbox/Git.pm | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 55005475..6b722023 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -108,9 +108,10 @@ sub new {
sub git_path ($$) {
my ($self, $path) = @_;
$self->{-git_path}->{$path} //= do {
- my $d = "$self->{git_dir}/$path";
- if (-e $d) {
- $d;
+ my $d = $self->{git_dir};
+ my $f = "$d/$path";
+ if (-d "$d/objects") {
+ $f;
} else {
local $/ = "\n";
my $rdr = { 2 => \my $err };
@@ -119,7 +120,7 @@ sub git_path ($$) {
chomp $s;
# git prior to 2.5.0 did not understand --git-path
- $s eq "--git-path\n$path" ? $d : $s;
+ $s eq "--git-path\n$path" ? $f : $s;
}
};
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-30 9:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-30 9:45 [PATCH 0/3] reduce synchronous waitpid calls Eric Wong
2024-05-30 9:45 ` [PATCH 1/3] gcf2: eliminate unnecessary autodie::close import Eric Wong
2024-05-30 9:45 ` [PATCH 2/3] git: prefer WNOHANG for `git cat-file --batch-*' Eric Wong
2024-05-30 9:45 ` [PATCH 3/3] git: reduce spawning for rev-parse --git-path Eric Wong
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).