about summary refs log tree commit homepage
path: root/lib/PublicInbox/CidxLogP.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-04-05 11:26:53 +0000
committerEric Wong <e@80x24.org>2023-04-05 20:12:12 +0000
commitcd115d4c99aa1134d3713d48101b9355423748e8 (patch)
tree53f1e207db8b7f60832d7744aec5e9326d4646c7 /lib/PublicInbox/CidxLogP.pm
parentb9905a03c5b76f999301f30ab839cb78293d661d (diff)
downloadpublic-inbox-cd115d4c99aa1134d3713d48101b9355423748e8.tar.gz
`git log -p' can several seconds to generate its initial output.
SMP systems can be processing prunes during this delay, so let
DS do a one-shot notification for us while prune is running.  On
Linux, we'll also use the biggest pipe possible so git can do
more CPU-intensive work to generate diffs while our Perl
processes are indexing and likely hitting I/O wait.
Diffstat (limited to 'lib/PublicInbox/CidxLogP.pm')
-rw-r--r--lib/PublicInbox/CidxLogP.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/PublicInbox/CidxLogP.pm b/lib/PublicInbox/CidxLogP.pm
new file mode 100644
index 00000000..7877d5ac
--- /dev/null
+++ b/lib/PublicInbox/CidxLogP.pm
@@ -0,0 +1,29 @@
+# Copyright (C) all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+#
+# Waits for initial `git log -p' output for PublicInbox::CodeSearchIdx.
+# The initial output from `git log -p' can take a while to generate,
+# CodeSearchIdx can process prune work while it's happening.  Once
+# `git log -p' starts generating output, it should be able to keep
+# up with Xapian indexing, so we still rely on blocking reads to simplify
+# cidx_read_log_p
+package PublicInbox::CidxLogP;
+use v5.12;
+use parent qw(PublicInbox::DS);
+use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
+
+sub new {
+        my ($cls, $rd, $cidx, $git, $roots) = @_;
+        my $self = bless { cidx => $cidx, git => $git, roots => $roots }, $cls;
+        fcntl($rd, 1031, 1048576) if $^O eq 'linux'; # fatter pipes
+        $self->SUPER::new($rd, EPOLLIN|EPOLLONESHOT);
+}
+
+sub event_step {
+        my ($self) = @_;
+        my $rd = $self->{sock} // return warn('BUG?: no {sock}');
+        $self->close; # PublicInbox::DS::close, deferred, so $sock is usable
+        delete($self->{cidx})->cidx_read_log_p($self, $rd);
+}
+
+1;