]> Sergey Matveev's repositories - public-inbox.git/blobdiff - Documentation/public-inbox-tuning.pod
lei rediff: add --drq and --dequote-only
[public-inbox.git] / Documentation / public-inbox-tuning.pod
index abc53d1ee0722c7561190bc805dcf5b4e6b81993..7b18b3bc403035e0eda5ab6dcb4d2059bdc3fb05 100644 (file)
@@ -16,7 +16,7 @@ New inboxes: public-inbox-init -V2
 
 =item 2
 
 
 =item 2
 
-Process spawning
+Optional Inline::C use
 
 =item 3
 
 
 =item 3
 
@@ -34,6 +34,14 @@ Performance on solid state drives
 
 Read-only daemons
 
 
 Read-only daemons
 
+=item 7
+
+Other OS tuning knobs
+
+=item 8
+
+Scalability to many inboxes
+
 =back
 
 =head2 New inboxes: public-inbox-init -V2
 =back
 
 =head2 New inboxes: public-inbox-init -V2
@@ -42,7 +50,7 @@ If you're starting a new inbox (and not mirroring an existing one),
 the L<-V2|public-inbox-v2-format(5)> requires L<DBD::SQLite>, but is
 orders of magnitude more scalable than the original C<-V1> format.
 
 the L<-V2|public-inbox-v2-format(5)> requires L<DBD::SQLite>, but is
 orders of magnitude more scalable than the original C<-V1> format.
 
-=head2 Process spawning
+=head2 Optional Inline::C use
 
 Our optional use of L<Inline::C> speeds up subprocess spawning from
 large daemon processes.
 
 Our optional use of L<Inline::C> speeds up subprocess spawning from
 large daemon processes.
@@ -52,9 +60,17 @@ environment variable to point to a writable directory, or create
 C<~/.cache/public-inbox/inline-c> for any user(s) running
 public-inbox processes.
 
 C<~/.cache/public-inbox/inline-c> for any user(s) running
 public-inbox processes.
 
+If libgit2 development files are installed and L<Inline::C>
+is enabled (described above), per-inbox C<git cat-file --batch>
+processes are replaced with a single L<perl(1)> process running
+C<PublicInbox::Gcf2::loop> in read-only daemons.  libgit2 use
+will be available in public-inbox 1.7.0+
+
 More (optional) L<Inline::C> use will be introduced in the future
 to lower memory use and improve scalability.
 
 More (optional) L<Inline::C> use will be introduced in the future
 to lower memory use and improve scalability.
 
+Note: L<Inline::C> is required for L<lei(1)>, but not public-inbox-*
+
 =head2 Performance on rotational hard disk drives
 
 Random I/O performance is poor on rotational HDDs.  Xapian indexing
 =head2 Performance on rotational hard disk drives
 
 Random I/O performance is poor on rotational HDDs.  Xapian indexing
@@ -69,11 +85,12 @@ footprint when indexing on HDDs.
 
 Initializing a mirror with a high C<--jobs> count to create more
 shards (in C<-V2> inboxes) will keep each shard smaller and
 
 Initializing a mirror with a high C<--jobs> count to create more
 shards (in C<-V2> inboxes) will keep each shard smaller and
-reduce its kernel page cache footprint.
+reduce its kernel page cache footprint.  Keep in mind excessive
+sharding imposes a performance penalty for read-only queries.
 
 Users with large amounts of RAM are advised to set a large value
 for C<publicinbox.indexBatchSize> as documented in
 
 Users with large amounts of RAM are advised to set a large value
 for C<publicinbox.indexBatchSize> as documented in
-L<public-inbox-config(5)>.
+L<public-inbox-index(1)>.
 
 C<dm-crypt> users on Linux 4.0+ are advised to try the
 C<--perf-same_cpu_crypt> C<--perf-submit_from_crypt_cpus>
 
 C<dm-crypt> users on Linux 4.0+ are advised to try the
 C<--perf-same_cpu_crypt> C<--perf-submit_from_crypt_cpus>
@@ -88,12 +105,23 @@ used by public-inbox are no exception to that.
 
 public-inbox 1.6.0+ disables copy-on-write (CoW) on Xapian and SQLite
 indices on btrfs to achieve acceptable performance (even on SSD).
 
 public-inbox 1.6.0+ disables copy-on-write (CoW) on Xapian and SQLite
 indices on btrfs to achieve acceptable performance (even on SSD).
-Disabling copy-on-write also disables checksumming, thus raid1
-(or higher) configurations may corrupt on unsafe shutdowns.
+Disabling copy-on-write also disables checksumming, thus C<raid1>
+(or higher) configurations may be corrupt after unsafe shutdowns.
 
 Fortunately, these SQLite and Xapian indices are designed to
 recoverable from git if missing.
 
 
 Fortunately, these SQLite and Xapian indices are designed to
 recoverable from git if missing.
 
+Disabling CoW does not prevent all fragmentation.  Large values
+of C<publicInbox.indexBatchSize> also limit fragmentation during
+the initial index.
+
+Avoid snapshotting subvolumes containing Xapian and/or SQLite indices.
+Snapshots use CoW despite our efforts to disable it, resulting
+in fragmentation.
+
+L<filefrag(8)> can be used to monitor fragmentation, and
+C<btrfs filesystem defragment -fr $INBOX_DIR> may be necessary.
+
 Large filesystems benefit significantly from the C<space_cache=v2>
 mount option documented in L<btrfs(5)>.
 
 Large filesystems benefit significantly from the C<space_cache=v2>
 mount option documented in L<btrfs(5)>.
 
@@ -106,6 +134,11 @@ While SSD read performance is generally good, SSD write performance
 degrades as the drive ages and/or gets full.  Issuing C<TRIM> commands
 via L<fstrim(8)> or similar is required to sustain write performance.
 
 degrades as the drive ages and/or gets full.  Issuing C<TRIM> commands
 via L<fstrim(8)> or similar is required to sustain write performance.
 
+Users of the Flash-Friendly File System
+L<F2FS|https://en.wikipedia.org/wiki/F2FS> may benefit from
+optimizations found in SQLite 3.21.0+.  Benchmarks are greatly
+appreciated.
+
 =head2 Read-only daemons
 
 L<public-inbox-httpd(1)>, L<public-inbox-imapd(1)>, and
 =head2 Read-only daemons
 
 L<public-inbox-httpd(1)>, L<public-inbox-imapd(1)>, and
@@ -116,12 +149,29 @@ for parallelism.
 
 The open file descriptor limit (C<RLIMIT_NOFILE>, C<ulimit -n> in L<sh(1)>,
 C<LimitNOFILE=> in L<systemd.exec(5)>) may need to be raised to
 
 The open file descriptor limit (C<RLIMIT_NOFILE>, C<ulimit -n> in L<sh(1)>,
 C<LimitNOFILE=> in L<systemd.exec(5)>) may need to be raised to
-accomodate many concurrent clients.
+accommodate many concurrent clients.
 
 Transport Layer Security (IMAPS, NNTPS, or via STARTTLS) significantly
 increases memory use of client sockets, sure to account for that in
 capacity planning.
 
 
 Transport Layer Security (IMAPS, NNTPS, or via STARTTLS) significantly
 increases memory use of client sockets, sure to account for that in
 capacity planning.
 
+=head2 Other OS tuning knobs
+
+Linux users: the C<sys.vm.max_map_count> sysctl may need to be increased if
+handling thousands of inboxes (with L<public-inbox-extindex(1)>) to avoid
+out-of-memory errors from git.
+
+Other OSes may have similar tuning knobs (patches appreciated).
+
+=head2 Scalability to many inboxes
+
+git 2.33+ startup time is orders-of-magnitude faster and uses
+less memory when dealing with thousands of alternates required
+for thousands of inboxes.
+
+L<public-inbox-extindex(1)> allows any number of public-inboxes
+to share the same Xapian indices.
+
 =head1 CONTACT
 
 Feedback encouraged via plain-text mail to L<mailto:meta@public-inbox.org>
 =head1 CONTACT
 
 Feedback encouraged via plain-text mail to L<mailto:meta@public-inbox.org>
@@ -130,10 +180,10 @@ Information for *BSDs and non-traditional filesystems especially
 welcome.
 
 Our archives are hosted at L<https://public-inbox.org/meta/>,
 welcome.
 
 Our archives are hosted at L<https://public-inbox.org/meta/>,
-L<http://hjrcffqmbrq6wope.onion/meta/>, and other places
+L<http://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/meta/>, and other places
 
 =head1 COPYRIGHT
 
 
 =head1 COPYRIGHT
 
-Copyright 2020 all contributors L<mailto:meta@public-inbox.org>
+Copyright 2020-2021 all contributors L<mailto:meta@public-inbox.org>
 
 License: AGPL-3.0+ L<https://www.gnu.org/licenses/agpl-3.0.txt>
 
 License: AGPL-3.0+ L<https://www.gnu.org/licenses/agpl-3.0.txt>