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 01/10] v2writable: introduce $sync state and put mm_tmp in it
  2019-05-29  8:28  6% [PATCH 00/10] index: support progress output Eric Wong
@ 2019-05-29  8:28  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2019-05-29  8:28 UTC (permalink / raw)
  To: meta

A first step towards making the v2 index_sync code
easier-to-follow.  More fields to follow...
---
 lib/PublicInbox/V2Writable.pm | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 331c4f4..584767a 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -706,7 +706,7 @@ sub mark_deleted {
 }
 
 sub reindex_oid {
-	my ($self, $mm_tmp, $D, $git, $oid, $regen, $reindex) = @_;
+	my ($self, $sync, $D, $git, $oid, $regen, $reindex) = @_;
 	my $len;
 	my $msgref = $git->cat_file($oid, \$len);
 	my $mime = PublicInbox::MIME->new($$msgref);
@@ -714,13 +714,13 @@ sub reindex_oid {
 	my $cid = content_id($mime);
 
 	# get the NNTP article number we used before, highest number wins
-	# and gets deleted from mm_tmp;
+	# and gets deleted from sync->{mm_tmp};
 	my $mid0;
 	my $num = -1;
 	my $del = 0;
 	foreach my $mid (@$mids) {
 		$del += delete($D->{"$mid\0$cid"}) ? 1 : 0;
-		my $n = $mm_tmp->num_for($mid);
+		my $n = $sync->{mm_tmp}->num_for($mid);
 		if (defined $n && $n > $num) {
 			$mid0 = $mid;
 			$num = $n;
@@ -764,7 +764,7 @@ sub reindex_oid {
 		return;
 
 	}
-	$mm_tmp->mid_delete($mid0) or
+	$sync->{mm_tmp}->mid_delete($mid0) or
 		die "failed to delete <$mid0> for article #$num\n";
 
 	$self->{over}->add_overview($mime, $len, $num, $oid, $mid0);
@@ -775,14 +775,14 @@ sub reindex_oid {
 	my $n = $self->{transact_bytes} += $len;
 	if ($n > (PublicInbox::SearchIdx::BATCH_BYTES * $nparts)) {
 		$git->cleanup;
-		$mm_tmp->atfork_prepare;
+		$sync->{mm_tmp}->atfork_prepare;
 		$self->done; # release lock
 
 		# TODO: print progress info, here
 
 		# allow -watch or -mda to write...
 		$self->idx_init; # reacquire lock
-		$mm_tmp->atfork_parent;
+		$sync->{mm_tmp}->atfork_parent;
 	}
 }
 
@@ -961,7 +961,9 @@ sub index_sync {
 	my $latest = git_dir_latest($self, \$epoch_max);
 	return unless defined $latest;
 	$self->idx_init($opts); # acquire lock
-	my $mm_tmp = $self->{mm}->tmp_clone;
+	my $sync = {
+		mm_tmp => $self->{mm}->tmp_clone,
+	};
 	my $reindex = $opts->{reindex};
 	my $ranges = index_ranges($self, $reindex, $epoch_max);
 
@@ -997,7 +999,7 @@ sub index_sync {
 			if (/\A$x40$/o && !defined($cmt)) {
 				$cmt = $_;
 			} elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o) {
-				$self->reindex_oid($mm_tmp, $D, $git, $1,
+				$self->reindex_oid($sync, $D, $git, $1,
 						$regen, $reindex);
 			} elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\td$/o) {
 				$self->mark_deleted($D, $git, $1);
@@ -1020,7 +1022,7 @@ sub index_sync {
 	# reindex does not pick up new changes, so we rerun w/o it:
 	if ($opts->{reindex}) {
 		my %again = %$opts;
-		$mm_tmp = undef;
+		$sync = undef;
 		delete @again{qw(reindex -skip_lock)};
 		index_sync($self, \%again);
 	}
-- 
EW


^ permalink raw reply related	[relevance 7%]

* [PATCH 00/10] index: support progress output
@ 2019-05-29  8:28  6% Eric Wong
  2019-05-29  8:28  7% ` [PATCH 01/10] v2writable: introduce $sync state and put mm_tmp in it Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2019-05-29  8:28 UTC (permalink / raw)
  To: meta

While progress support was implemented for -xcpdb, there was no
way to enable it for the -index command; and v2 progress was
lacking compared to v1.

This series fills in those functionality gaps and cleans up some
of the v2 indexing code at the same time.

Eric Wong (10):
  v2writable: introduce $sync state and put mm_tmp in it
  v2writable: sync: move delete markers into $sync state
  v2writable: move {reindex} field to $sync state
  v2writable: move {regen} into $sync state
  v2writable: move {ranges} into $sync state
  v2writable: localize unindex-range.$EPOCH to $sync state
  v2writable: use prototypes for internal subs
  v2writable: move index_sync options to sync state
  index: support --verbose option
  v2writable: show progress updates for index_sync

 lib/PublicInbox/Admin.pm      |  18 ++++
 lib/PublicInbox/V2Writable.pm | 178 +++++++++++++++++++---------------
 lib/PublicInbox/Xapcmd.pm     |  14 +--
 script/public-inbox-index     |   5 +-
 4 files changed, 124 insertions(+), 91 deletions(-)

-- 
EW


^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-05-29  8:28  6% [PATCH 00/10] index: support progress output Eric Wong
2019-05-29  8:28  7% ` [PATCH 01/10] v2writable: introduce $sync state and put mm_tmp in it 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).