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 04/26] search: reenable phrase search on non-chert Xapian
  2019-05-23  9:36  6% [PATCH 00/26] xcpdb: ease Xapian DB format migrations Eric Wong
@ 2019-05-23  9:36  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2019-05-23  9:36 UTC (permalink / raw)
  To: meta

This is assuming nobody uses flint or earlier, anymore;
as flint predates the existence of this project.
---
 lib/PublicInbox/Search.pm | 48 +++++++++++++++++++++++----------------
 t/search.t                |  1 +
 2 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index eae10d8..d861cf4 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -24,8 +24,8 @@ sub load_xapian () {
 
 		# n.b. FLAG_PURE_NOT is expensive not suitable for a public
 		# website as it could become a denial-of-service vector
-		# FLAG_PHRASE also seems to cause performance problems
-		# sometimes.
+		# FLAG_PHRASE also seems to cause performance problems chert
+		# (and probably earlier Xapian DBs).  glass seems fine...
 		# TODO: make this an option, maybe?
 		# or make indexlevel=medium as default
 		FLAG_PHRASE()|FLAG_BOOLEAN()|FLAG_LOVEHATE()|FLAG_WILDCARD();
@@ -137,26 +137,35 @@ sub xdir ($;$) {
 	}
 }
 
+sub _xdb ($) {
+	my ($self) = @_;
+	my $dir = xdir($self, 1);
+	my ($xdb, $slow_phrase);
+	my $qpf = \($self->{qp_flags} ||= $QP_FLAGS);
+	if ($self->{version} >= 2) {
+		foreach my $part (<$dir/*>) {
+			-d $part && $part =~ m!/\d+\z! or next;
+			my $sub = Search::Xapian::Database->new($part);
+			if ($xdb) {
+				$xdb->add_database($sub);
+			} else {
+				$xdb = $sub;
+			}
+			$slow_phrase ||= -f "$part/iamchert";
+		}
+	} else {
+		$slow_phrase = -f "$dir/iamchert";
+		$xdb = Search::Xapian::Database->new($dir);
+	}
+	$$qpf |= FLAG_PHRASE() unless $slow_phrase;
+	$xdb;
+}
+
 sub xdb ($) {
 	my ($self) = @_;
 	$self->{xdb} ||= do {
 		load_xapian();
-		my $dir = xdir($self, 1);
-		if ($self->{version} >= 2) {
-			my $xdb;
-			foreach my $part (<$dir/*>) {
-				-d $part && $part =~ m!/\d+\z! or next;
-				my $sub = Search::Xapian::Database->new($part);
-				if ($xdb) {
-					$xdb->add_database($sub);
-				} else {
-					$xdb = $sub;
-				}
-			}
-			$xdb;
-		} else {
-			Search::Xapian::Database->new($dir);
-		}
+		_xdb($self);
 	};
 }
 
@@ -194,7 +203,8 @@ sub query {
 		$self->{over_ro}->recent($opts);
 	} else {
 		my $qp = qp($self);
-		my $query = $qp->parse_query($query_string, $QP_FLAGS);
+		my $qp_flags = $self->{qp_flags};
+		my $query = $qp->parse_query($query_string, $qp_flags);
 		$opts->{relevance} = 1 unless exists $opts->{relevance};
 		_do_enquire($self, $query, $opts);
 	}
diff --git a/t/search.t b/t/search.t
index c063620..538baef 100644
--- a/t/search.t
+++ b/t/search.t
@@ -30,6 +30,7 @@ my $ro = PublicInbox::Search->new($git_dir);
 my $rw_commit = sub {
 	$rw->commit_txn_lazy if $rw;
 	$rw = PublicInbox::SearchIdx->new($git_dir, 1);
+	$rw->{qp_flags} = 0; # quiet a warning
 	$rw->begin_txn_lazy;
 };
 
-- 
EW


^ permalink raw reply related	[relevance 7%]

* [PATCH 00/26] xcpdb: ease Xapian DB format migrations
@ 2019-05-23  9:36  6% Eric Wong
  2019-05-23  9:36  7% ` [PATCH 04/26] search: reenable phrase search on non-chert Xapian Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2019-05-23  9:36 UTC (permalink / raw)
  To: meta

I've noticed performance problems in Xapian's old chert
backend which seem alleviated with the new glass backend;
particularly related to phrase searches.

Unfortunately, the tool distributed with Xapian for updating DB
formats, copydatabase(1), is extremely slow and blocking updates
for hours at a time to perform the migration is not acceptable.
(That's right, "copydatabase" is NOT a Postgres command!)

So, I've written "public-inbox-xcpdb" and gotten it to perform
the bulk copy operation without holding inbox.lock and have it
deal gracefully with Xapian DB modifications.  xcpdb is still
slow, but I've (finally!) implemented partial reindexing to
allow it to minimize the lock time and not stall -mda or -watch
processes while it is working.

There's a bunch of cleanups along the way, too; and it should
make future changes to repartition the Xapian DB on existing v2
inboxes easier.

Eric Wong (26):
  t/convert-compact: skip on missing xapian-compact(1)
  v1writable: retire in favor of InboxWritable
  doc: document the reason for --no-renumber
  search: reenable phrase search on non-chert Xapian
  xapcmd: new module for wrapping Xapian commands
  admin: hoist out resolve_inboxes for -compact and -index
  xapcmd: support spawn options
  xcpdb: new tool which wraps Xapian's copydatabase(1)
  xapcmd: do not cleanup on errors
  admin: move index_inbox over
  xcpdb: implement using Perl bindings
  xapcmd: xcpdb supports compaction
  v2writable: hoist out log_range sub for readability
  xcpdb: use fine-grained locking
  xcpdb: implement progress reporting
  xcpdb: cleanup error handling and diagnosis
  xapcmd: avoid EXDEV when finalizing changes
  doc: xcpdb: update to reflect the current state
  xapcmd: use "print STDERR" for progress reporting
  xcpdb: show re-indexing progress
  xcpdb: remove temporary directories on aborts
  compact: reuse infrastructure from xcpdb
  xcpdb|compact: support some xapian-compact switches
  xapcmd: cleanup on interrupted xcpdb "--compact"
  xcpdb|compact: support --jobs/-j flag like gmake(1)
  xapcmd: do not reset %SIG until last Xtmpdir is done

 Documentation/include.mk                 |   6 +-
 Documentation/public-inbox-v1-format.pod |   4 +
 Documentation/public-inbox-v2-format.pod |   4 +
 Documentation/public-inbox-xcpdb.pod     |  57 ++++
 MANIFEST                                 |   4 +-
 lib/PublicInbox/Admin.pm                 |  66 ++++
 lib/PublicInbox/InboxWritable.pm         |  35 ++-
 lib/PublicInbox/Search.pm                |  48 +--
 lib/PublicInbox/SearchIdx.pm             |  34 ++-
 lib/PublicInbox/V1Writable.pm            |  34 ---
 lib/PublicInbox/V2Writable.pm            | 109 ++++---
 lib/PublicInbox/Xapcmd.pm                | 370 +++++++++++++++++++++++
 script/public-inbox-compact              | 102 +------
 script/public-inbox-index                | 102 +------
 script/public-inbox-init                 |  13 +-
 script/public-inbox-xcpdb                |  19 ++
 t/cgi.t                                  |   4 +-
 t/convert-compact.t                      |   4 +
 t/indexlevels-mirror.t                   |  27 +-
 t/init.t                                 |   4 +-
 t/nntpd.t                                |  15 +-
 t/search.t                               |   1 +
 t/v2mirror.t                             |   1 +
 23 files changed, 740 insertions(+), 323 deletions(-)
 create mode 100644 Documentation/public-inbox-xcpdb.pod
 delete mode 100644 lib/PublicInbox/V1Writable.pm
 create mode 100644 lib/PublicInbox/Xapcmd.pm
 create mode 100755 script/public-inbox-xcpdb

-- 
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-23  9:36  6% [PATCH 00/26] xcpdb: ease Xapian DB format migrations Eric Wong
2019-05-23  9:36  7% ` [PATCH 04/26] search: reenable phrase search on non-chert Xapian 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).