diff options
author | Eric Wong <e@80x24.org> | 2022-03-07 10:57:37 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-03-08 00:30:03 +0000 |
commit | 3eec2f7792040f75f3988c520f308e2445baf645 (patch) | |
tree | e581cdd77765c84ae870999f36193e4302f5df71 /lib/PublicInbox/SearchIdx.pm | |
parent | 798bd392d273735a69f0b009e70d8bb2dbc4a7e4 (diff) | |
download | public-inbox-3eec2f7792040f75f3988c520f308e2445baf645.tar.gz |
This enables Xapian::DB_DANGEROUS to support in-place updates. This can speed up the initial index and reduce I/O at the cost of preventing concurrent readers and being unsafe in the face of any abnormal terminations. This is more dangerous than --no-fsync. --no-fsync is only unsafe in the event of a power loss or kernel crash; --dangerous is unsafe even on SIGKILL.
Diffstat (limited to 'lib/PublicInbox/SearchIdx.pm')
-rw-r--r-- | lib/PublicInbox/SearchIdx.pm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 95b14c3a..85fae4ad 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -30,6 +30,7 @@ our @EXPORT_OK = qw(log2stack is_ancestor check_size prepare_stack my $X = \%PublicInbox::Search::X; our ($DB_CREATE_OR_OPEN, $DB_OPEN); our $DB_NO_SYNC = 0; +our $DB_DANGEROUS = 0; our $BATCH_BYTES = $ENV{XAPIAN_FLUSH_THRESHOLD} ? 0x7fffffff : # assume a typical 64-bit system has 8x more RAM than a # typical 32-bit system: @@ -115,7 +116,10 @@ sub load_xapian_writable () { my $ver = (eval($xap.'::major_version()') << 16) | (eval($xap.'::minor_version()') << 8) | eval($xap.'::revision()'); - $DB_NO_SYNC = 0x4 if $ver >= 0x10400; + if ($ver >= 0x10400) { + $DB_NO_SYNC = 0x4; + $DB_DANGEROUS = 0x10; + } # Xapian v1.2.21..v1.2.24 were missing close-on-exec on OFD locks $X->{CLOEXEC_UNSET} = 1 if $ver >= 0x010215 && $ver <= 0x010218; 1; @@ -142,6 +146,9 @@ sub idx_acquire { require PublicInbox::Syscall; PublicInbox::Syscall::nodatacow_dir($dir); $self->{-set_has_threadid_once} = 1; + if (($self->{ibx} // $self->{eidx})->{-dangerous}) { + $flag |= $DB_DANGEROUS; + } } } return unless defined $flag; |