From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 08/15] cindex: skip getpid guard for most OnDestroy use
Date: Thu, 30 Nov 2023 11:41:01 +0000 [thread overview]
Message-ID: <20231130114109.2577708-9-e@80x24.org> (raw)
In-Reply-To: <20231130114109.2577708-1-e@80x24.org>
We no longer fork after cidx_init, so there's no need to spend
CPU cycles on the getpid() syscall, especially since it's no
longer cached on glibc while syscalls are also more expensive
these days due to CPU vulnerability mitigations.
---
lib/PublicInbox/CodeSearchIdx.pm | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm
index 7580a49a..555a1efe 100644
--- a/lib/PublicInbox/CodeSearchIdx.pm
+++ b/lib/PublicInbox/CodeSearchIdx.pm
@@ -365,7 +365,7 @@ sub repo_stored {
$did > 0 or die "BUG: $repo_ctx->{repo}->{git_dir}: docid=$did";
my ($c, $p) = PublicInbox::PktOp->pair;
$c->{ops}->{shard_done} = [ $self, $repo_ctx,
- PublicInbox::OnDestroy->new($$, \&next_repos, $repo_ctx, $drs)];
+ PublicInbox::OnDestroy->new(\&next_repos, $repo_ctx, $drs)];
# shard_done fires when all shards are committed
my @active = keys %{$repo_ctx->{active}};
$IDX_SHARDS[$_]->wq_io_do('shard_commit', [ $p->{op_p} ]) for @active;
@@ -607,8 +607,8 @@ sub index_next ($) {
index_repo(undef, $self, shift @$IDXQ);
} elsif ($SCANQ && @$SCANQ) {
my $git = shift @$SCANQ;
- my $prep_repo = PublicInbox::OnDestroy->new($$, \&prep_repo,
- $self, $git);
+ my $prep_repo = PublicInbox::OnDestroy->new(\&prep_repo,
+ $self, $git);
fp_start($self, $git, $prep_repo);
ct_start($self, $git, $prep_repo);
} elsif ($TMPDIR) {
@@ -669,7 +669,7 @@ sub index_repo { # run_git cb
my $repo_ctx = $REPO_CTX = { self => $self, repo => $repo };
delete $git->{-cidx_gits_fini}; # may fire gits_fini
my $drs = delete $git->{-cidx_dump_roots_start};
- my $index_done = PublicInbox::OnDestroy->new($$, \&index_done,
+ my $index_done = PublicInbox::OnDestroy->new(\&index_done,
$repo_ctx, $drs);
my ($c, $p) = PublicInbox::PktOp->pair;
$c->{ops}->{shard_done} = [ $self, $repo_ctx, $index_done ];
@@ -779,7 +779,7 @@ sub scan_git_dirs ($) {
my ($self) = @_;
@$SCANQ = () unless $self->{-opt}->{scan};
$GITS_NR = @$SCANQ or return;
- my $gits_fini = PublicInbox::OnDestroy->new($$, \&gits_fini);
+ my $gits_fini = PublicInbox::OnDestroy->new(\&gits_fini);
$_->{-cidx_gits_fini} = $gits_fini for @$SCANQ;
if (my $drs = $TODO{dump_roots_start}) {
$_->{-cidx_dump_roots_start} = $drs for @$SCANQ;
@@ -851,7 +851,7 @@ sub prep_umask ($) {
umask == $um or progress($self, 'using umask from ',
$self->{cidx_dir}, ': ',
sprintf('0%03o', $um));
- PublicInbox::OnDestroy->new($$, \&CORE::umask, umask($um));
+ PublicInbox::OnDestroy->new(\&CORE::umask, umask($um));
} else {
$self->{umask} = umask; # for SearchIdx->with_umask
undef;
@@ -1073,11 +1073,11 @@ EOM
($JOIN_DT[1]) = ($QRY_STR =~ /\.\.([0-9]{14})\z/); # YYYYmmddHHMMSS
($JOIN_DT[0]) = ($QRY_STR =~ /\Adt:([0-9]{14})/); # YYYYmmddHHMMSS
$JOIN_DT[0] //= '19700101'.'000000'; # git uses unsigned times
- $TODO{do_join} = PublicInbox::OnDestroy->new($$, \&do_join, $self);
+ $TODO{do_join} = PublicInbox::OnDestroy->new(\&do_join, $self);
$TODO{joining} = 1; # keep shards_active() happy
- $TODO{dump_ibx_start} = PublicInbox::OnDestroy->new($$,
- \&dump_ibx_start, $self, $TODO{do_join});
- $TODO{dump_roots_start} = PublicInbox::OnDestroy->new($$,
+ $TODO{dump_ibx_start} = PublicInbox::OnDestroy->new(\&dump_ibx_start,
+ $self, $TODO{do_join});
+ $TODO{dump_roots_start} = PublicInbox::OnDestroy->new(
\&dump_roots_start, $self, $TODO{do_join});
progress($self, "will join in $QRY_STR date range...");
my $id = -1;
@@ -1100,7 +1100,7 @@ sub init_prune ($) {
require_progs('prune', 'xapian-delve' => \@delve, sed => \@sed,
comm => \@COMM, awk => \@AWK);
for (0..$#IDX_SHARDS) { push @delve, "$self->{xpfx}/$_" }
- my $run_prune = PublicInbox::OnDestroy->new($$, \&run_prune, $self,
+ my $run_prune = PublicInbox::OnDestroy->new(\&run_prune, $self,
$TODO{dump_roots_start});
my ($sort_opt, $sed_opt, $delve_opt);
pipe(local $sed_opt->{0}, local $delve_opt->{1});
next prev parent reply other threads:[~2023-11-30 11:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 11:40 [PATCH 00/15] various cindex fixes + speedups Eric Wong
2023-11-30 11:40 ` [PATCH 01/15] cindex: fix store_repo+repo_stored on no-op Eric Wong
2023-11-30 11:40 ` [PATCH 02/15] codesearch: allow inbox count to exceed matches Eric Wong
2023-11-30 11:40 ` [PATCH 03/15] config: reject newlines consistently in dir names Eric Wong
2023-11-30 11:40 ` [PATCH 04/15] cindex: only create {-cidx_err} field on failures Eric Wong
2023-11-30 11:40 ` [PATCH 05/15] cindex: keep batch pipe for pruning SHA-256 repos Eric Wong
2023-11-30 11:40 ` [PATCH 06/15] cindex: store extensions.objectFormat with repo data Eric Wong
2023-11-30 21:36 ` Eric Wong
2023-11-30 11:41 ` [PATCH 07/15] git: share unlinked pack checking code with gcf2 Eric Wong
2023-11-30 11:41 ` Eric Wong [this message]
2023-11-30 11:41 ` [PATCH 09/15] spawn: drop IO layer support from redirects Eric Wong
2023-11-30 11:41 ` [PATCH 10/15] cindex: speed up initial scan setup phase Eric Wong
2023-11-30 11:41 ` [PATCH 11/15] inbox: expire resources more aggressively Eric Wong
2023-11-30 11:41 ` [PATCH 12/15] git_async_cat: use git from "all" extindex if possible Eric Wong
2023-11-30 11:41 ` [PATCH 13/15] www_listing: support publicInbox.nameIsUrl Eric Wong
2023-12-01 1:29 ` Kyle Meyer
2023-12-01 2:01 ` [PATCH] doc: config: fix grammar for nameIsUrl Eric Wong
2023-11-30 11:41 ` [PATCH 14/15] inbox: shrink data structures for publicinbox.*.hide Eric Wong
2023-11-30 11:41 ` [PATCH 15/15] codesearch: use retry_reopen for WWW Eric Wong
2023-11-30 21:40 ` [PATCH v2] " Eric Wong
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
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231130114109.2577708-9-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).