mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-27 01:48:09 -07:00
add man for lmdb storage
* update dependencies
This commit is contained in:
@@ -0,0 +1,211 @@
|
||||
# Hardware
|
||||
|
||||
* CPU: Intel i5-12500H
|
||||
* RAM: 16GiB (2x8 Samsung M471A1K43EB1-CWE)
|
||||
* Storage: NVME SSD Samsung 980PRO
|
||||
* OS: Ubuntu 22.04
|
||||
|
||||
# Benchmarks
|
||||
# Memory
|
||||
|
||||
```
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/sot-tech/mochi/storage/memory
|
||||
cpu: 12th Gen Intel(R) Core(TM) i5-12500H
|
||||
BenchmarkStorage/BenchmarkNop-16 1000000000 0.1822 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut-16 7071364 173.1 ns/op 80 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1k-16 5342302 280.4 ns/op 80 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash-16 17775769 65.81 ns/op 80 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash1k-16 15953836 68.41 ns/op 80 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete-16 4975660 237.0 ns/op 160 B/op 4 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1k-16 4842673 240.3 ns/op 160 B/op 4 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash-16 4597555 248.2 ns/op 160 B/op 4 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash1k-16 4776769 265.1 ns/op 160 B/op 4 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist-16 19164670 60.77 ns/op 96 B/op 3 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1k-16 29773471 42.81 ns/op 96 B/op 3 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash-16 38686660 32.11 ns/op 96 B/op 3 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash1k-16 36604658 32.88 ns/op 96 B/op 3 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete-16 2982174 419.8 ns/op 240 B/op 6 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1k-16 2881537 407.3 ns/op 240 B/op 6 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash-16 2654642 443.4 ns/op 240 B/op 6 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash1k-16 2630800 462.8 ns/op 240 B/op 6 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist-16 6837140 203.3 ns/op 80 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1k-16 5347960 267.2 ns/op 80 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash-16 15773694 75.18 ns/op 80 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash1k-16 16675423 73.16 ns/op 80 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher-16 1368090 823.9 ns/op 4496 B/op 3 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher1kInfoHash-16 1401063 823.8 ns/op 4496 B/op 3 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder-16 4446224 273.7 ns/op 1424 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder1kInfoHash-16 4279449 280.8 ns/op 1424 B/op 2 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm-16 16012303 67.37 ns/op 16 B/op 1 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm1kInfoHash-16 82122622 14.58 ns/op 16 B/op 1 allocs/op
|
||||
PASS
|
||||
ok github.com/sot-tech/mochi/storage/memory 41.848s
|
||||
```
|
||||
|
||||
# Redis
|
||||
|
||||
Version: 6.0.16
|
||||
|
||||
Configuration: OOTB
|
||||
|
||||
```
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/sot-tech/mochi/storage/redis
|
||||
cpu: 12th Gen Intel(R) Core(TM) i5-12500H
|
||||
BenchmarkStorage/BenchmarkNop-16 1000000000 0.1611 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut-16 180381 6148 ns/op 1257 B/op 37 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1k-16 203150 6314 ns/op 1273 B/op 37 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash-16 196033 6187 ns/op 1249 B/op 37 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash1k-16 202513 6176 ns/op 1265 B/op 37 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete-16 26925 40429 ns/op 1736 B/op 56 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1k-16 27751 39310 ns/op 1768 B/op 56 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash-16 28142 41585 ns/op 1720 B/op 56 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash1k-16 29500 39063 ns/op 1752 B/op 56 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist-16 281184 4451 ns/op 320 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1k-16 235394 4316 ns/op 334 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash-16 272566 4569 ns/op 312 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash1k-16 278380 4315 ns/op 326 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete-16 20154 64004 ns/op 3664 B/op 108 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1k-16 19230 61428 ns/op 3712 B/op 108 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash-16 18270 62749 ns/op 3632 B/op 108 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash1k-16 20653 60017 ns/op 3680 B/op 108 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist-16 157063 7336 ns/op 1929 B/op 52 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1k-16 161649 7598 ns/op 1945 B/op 52 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash-16 163005 7436 ns/op 1913 B/op 52 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash1k-16 151135 7524 ns/op 1929 B/op 52 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher-16 70124 16813 ns/op 15277 B/op 83 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher1kInfoHash-16 71144 17011 ns/op 15261 B/op 83 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder-16 149967 8055 ns/op 6814 B/op 42 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder1kInfoHash-16 141770 8202 ns/op 6806 B/op 42 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm-16 55156 21739 ns/op 1120 B/op 41 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm1kInfoHash-16 58994 21821 ns/op 1087 B/op 41 allocs/op
|
||||
PASS
|
||||
ok github.com/sot-tech/mochi/storage/redis 43.235s
|
||||
```
|
||||
|
||||
## KeyDB
|
||||
|
||||
Version: 6.3.4
|
||||
|
||||
Configuration: OOTB
|
||||
|
||||
```
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/sot-tech/mochi/storage/keydb
|
||||
cpu: 12th Gen Intel(R) Core(TM) i5-12500H
|
||||
BenchmarkStorage/BenchmarkNop-16 1000000000 0.1873 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut-16 141714 8824 ns/op 553 B/op 21 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1k-16 141138 9215 ns/op 566 B/op 21 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash-16 113070 8939 ns/op 546 B/op 21 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash1k-16 134258 8578 ns/op 558 B/op 21 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete-16 31476 37899 ns/op 856 B/op 33 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1k-16 34111 35877 ns/op 880 B/op 33 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash-16 31716 35344 ns/op 840 B/op 33 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash1k-16 33234 37156 ns/op 864 B/op 33 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist-16 292579 4302 ns/op 320 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1k-16 289604 4401 ns/op 334 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash-16 272372 4297 ns/op 312 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash1k-16 284304 4165 ns/op 326 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete-16 23744 49850 ns/op 1304 B/op 48 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1k-16 23378 53921 ns/op 1344 B/op 48 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash-16 25268 49024 ns/op 1272 B/op 48 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash1k-16 21583 50219 ns/op 1312 B/op 48 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist-16 133311 8960 ns/op 669 B/op 24 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1k-16 134439 8884 ns/op 683 B/op 24 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash-16 130093 9005 ns/op 653 B/op 24 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash1k-16 137900 8774 ns/op 667 B/op 24 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher-16 75067 16103 ns/op 15276 B/op 83 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher1kInfoHash-16 72286 16315 ns/op 15261 B/op 83 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder-16 165186 7705 ns/op 6814 B/op 42 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder1kInfoHash-16 151609 7799 ns/op 6806 B/op 42 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm-16 54744 21244 ns/op 1120 B/op 41 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm1kInfoHash-16 54865 21736 ns/op 1088 B/op 41 allocs/op
|
||||
PASS
|
||||
ok github.com/sot-tech/mochi/storage/keydb 44.466s
|
||||
```
|
||||
|
||||
## PostgreSQL
|
||||
|
||||
Version: 14.12
|
||||
|
||||
Configuration: OOTB
|
||||
|
||||
```
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/sot-tech/mochi/storage/pg
|
||||
cpu: 12th Gen Intel(R) Core(TM) i5-12500H
|
||||
BenchmarkStorage/BenchmarkNop-16 1000000000 0.1687 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut-16 58521 19857 ns/op 2213 B/op 44 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1k-16 153538 7259 ns/op 2208 B/op 44 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash-16 151515 7319 ns/op 2204 B/op 44 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash1k-16 165950 7452 ns/op 2211 B/op 44 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete-16 17130 61564 ns/op 4274 B/op 81 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1k-16 19200 60632 ns/op 4285 B/op 81 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash-16 19923 59570 ns/op 4273 B/op 81 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash1k-16 20510 61910 ns/op 4285 B/op 80 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist-16 184810 5485 ns/op 2098 B/op 37 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1k-16 187735 5514 ns/op 2108 B/op 37 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash-16 217992 5621 ns/op 2099 B/op 37 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash1k-16 215710 5569 ns/op 2109 B/op 37 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete-16 8280 139091 ns/op 7306 B/op 143 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1k-16 9010 133127 ns/op 7320 B/op 143 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash-16 8030 133810 ns/op 7305 B/op 143 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash1k-16 8217 136543 ns/op 7321 B/op 143 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist-16 20883 56024 ns/op 3101 B/op 62 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1k-16 20932 55863 ns/op 3106 B/op 62 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash-16 77368 15365 ns/op 3067 B/op 62 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash1k-16 65448 15568 ns/op 3081 B/op 62 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher-16 55521 21614 ns/op 22565 B/op 380 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher1kInfoHash-16 54933 21813 ns/op 22571 B/op 380 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder-16 117950 10443 ns/op 9239 B/op 190 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder1kInfoHash-16 113031 10490 ns/op 9242 B/op 190 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm-16 103208 11945 ns/op 2951 B/op 46 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm1kInfoHash-16 101088 12110 ns/op 2952 B/op 46 allocs/op
|
||||
PASS
|
||||
ok github.com/sot-tech/mochi/storage/pg 64.953s
|
||||
```
|
||||
|
||||
## LMDB
|
||||
|
||||
Version: 0.9.31
|
||||
|
||||
```
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
pkg: github.com/sot-tech/mochi/storage/mdb
|
||||
cpu: 12th Gen Intel(R) Core(TM) i5-12500H
|
||||
BenchmarkStorage/BenchmarkNop-16 1000000000 0.1721 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut-16 327027 3127 ns/op 268 B/op 6 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1k-16 320313 4422 ns/op 268 B/op 6 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash-16 295910 4002 ns/op 260 B/op 6 allocs/op
|
||||
BenchmarkStorage/BenchmarkPut1kInfoHash1k-16 258867 4967 ns/op 260 B/op 6 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete-16 299650 3814 ns/op 568 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1k-16 293272 4041 ns/op 568 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash-16 268844 4367 ns/op 552 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash1k-16 254877 4553 ns/op 552 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist-16 420516 4119 ns/op 372 B/op 11 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1k-16 218998 4668 ns/op 372 B/op 11 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash-16 308973 3916 ns/op 364 B/op 11 allocs/op
|
||||
BenchmarkStorage/BenchmarkDeleteNonexist1kInfoHash1k-16 391814 3435 ns/op 364 B/op 11 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete-16 152656 7754 ns/op 876 B/op 22 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1k-16 153908 7915 ns/op 876 B/op 22 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash-16 130611 9273 ns/op 852 B/op 22 allocs/op
|
||||
BenchmarkStorage/BenchmarkPutGradDelete1kInfoHash1k-16 127370 9124 ns/op 852 B/op 22 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist-16 209017 5403 ns/op 380 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1k-16 225026 6203 ns/op 380 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash-16 184981 6386 ns/op 372 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkGradNonexist1kInfoHash1k-16 181864 5550 ns/op 372 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher-16 676172 1937 ns/op 3648 B/op 15 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceLeecher1kInfoHash-16 639292 2022 ns/op 3636 B/op 15 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder-16 926640 1300 ns/op 3416 B/op 10 allocs/op
|
||||
BenchmarkStorage/BenchmarkAnnounceSeeder1kInfoHash-16 880938 1390 ns/op 3404 B/op 10 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm-16 2990839 399.6 ns/op 344 B/op 13 allocs/op
|
||||
BenchmarkStorage/BenchmarkScrapeSwarm1kInfoHash-16 3079238 382.5 ns/op 332 B/op 13 allocs/op
|
||||
PASS
|
||||
ok github.com/sot-tech/mochi/storage/mdb 46.359s
|
||||
```
|
||||
@@ -0,0 +1,115 @@
|
||||
# LMDB Storage
|
||||
|
||||
This storage uses LMDB persistent key-value database to store peer and/or arbitrary key-value data.
|
||||
|
||||
_Note: **requires** CGO-enabled build (`CGO_ENABLED=1 go install...`),
|
||||
because of native bindings to C LMDB code._
|
||||
|
||||
# Use case
|
||||
|
||||
LMDB may be used in local installation to read/write data from/to (local or network mounted)
|
||||
filesystem directly, without network stack.
|
||||
|
||||
It supports multi-thread/process (multi-reader, single-writer) access, and DB size larger than RAM,
|
||||
so *may* be used within several applications as shared store, e.g. external app can modify allowed/denied
|
||||
info hashes for `torrentapproval` middleware or mochi cluster with shared DB over NFS.
|
||||
|
||||
As it filesystem database, performance is also depends on filesystem/disk performance, so it *may*
|
||||
be slower than tuned PostgreSQL or Redis.
|
||||
|
||||
## Configuration and implementation notes
|
||||
|
||||
Basically LDMB environment is a directory with 2 files: data.mdb and lock.mdb, which will be created on start.
|
||||
Each *environment* may contain several named databases. If name for specific database (for peers and arbitrary data)
|
||||
is not provided, default (0-th) database is used, which is *NOT* recommended, because is contains internal information.
|
||||
|
||||
Both stored key and value are byte arrays.
|
||||
Arbitrary DB key format is `<PREFIX>_<KEY>`, value is byte array converted string.
|
||||
|
||||
Peers DB format is:
|
||||
|
||||
1. Key `<PREFIX>_<INFOHASH>_<PEERID><IPADDRESS><PORT>`, value - BE-encoded unix timestamp.
|
||||
Fields:
|
||||
* `<PREFIX>` - `L4`, `L6`, `S4`, `S6` string for leecher with IPv4 or IPv6 address, or seeder with IPv4 or IPv6 address (accordingly)
|
||||
* `<INFOHASH>` - 20 or 32 bytes of info hash (V1 or V2 accordingly)
|
||||
* `<PEERID>` - 20 bytes of peer ID
|
||||
* `<IPADDRESS>` - 16 bytes of BE-encoded IP address (real IPv6 or IPv4-mapped IPv6 address)
|
||||
* `<PORT>` - 2 bytes of BE-encoded port
|
||||
2. Key `<PREFIX>_<INFOHASH>_`, value - BE-encoded unsigned 32-bit integer.
|
||||
`<PREFIX>` is `LC`, `SC`, `DC` string for leechers, seeders or downloaded count of specified `<INFOHASH>` (20 or 32 bytes).
|
||||
|
||||
Write speed may be increased with `no_sync_meta` and `async_write` configuration options,
|
||||
but the risk of DB corruption is also increase.
|
||||
|
||||
With `async_write` option, write speed will be a little faster than locally installed OOTB Redis,
|
||||
but application will use more RAM (dirty pages).
|
||||
Without it, you will get dramatically slow write speed: every write transaction will be flushed to disk.
|
||||
|
||||
Option `no_sync_meta` **without** `async_write` will increase write speed up to 3 times
|
||||
(with potential loss of last transaction if application crashed/killed).
|
||||
|
||||
Both enabled options don't make much sense and also don't affect read performance.
|
||||
|
||||
Benchmarks with combinations of options above:
|
||||
|
||||
```
|
||||
async_write=false, no_sync_meta=false
|
||||
BenchmarkStorage/BenchmarkPutGradDelete-16 123 9000653 ns/op
|
||||
|
||||
async_write=false, no_sync_meta=true
|
||||
BenchmarkStorage/BenchmarkPutDelete1kInfoHash1k-16 306 4001353 ns/op
|
||||
|
||||
async_write=true, no_sync_meta=false
|
||||
BenchmarkStorage/BenchmarkPutGradDelete-16 152656 7754 ns/op
|
||||
|
||||
async_write=true, no_sync_meta=true
|
||||
BenchmarkStorage/BenchmarkPutGradDelete-16 150116 7735 ns/op
|
||||
```
|
||||
|
||||
**Sample configuration:**
|
||||
|
||||
```yaml
|
||||
storage:
|
||||
name: lmdb
|
||||
config:
|
||||
# The frequency which stale peers are removed.
|
||||
# This balances between
|
||||
# - collecting garbage more often, potentially using more CPU time, but potentially using less memory (lower value)
|
||||
# - collecting garbage less frequently, saving CPU time, but keeping old peers long, thus using more memory (higher value).
|
||||
gc_interval: 3m
|
||||
|
||||
# The amount of time until a peer is considered stale.
|
||||
# To avoid churn, keep this slightly larger than `announce_interval`
|
||||
peer_lifetime: 31m
|
||||
|
||||
# Path to LMDB folder. Required.
|
||||
Path: "/some/path/to/lmdb/directory"
|
||||
|
||||
# File mode of created database files, default is 0o640
|
||||
mode: 0640
|
||||
|
||||
# Name of database to store KV data. If not provided, root DB is used (not recommended)
|
||||
data_db: "DATA"
|
||||
|
||||
# Name of database to store peers data. If not provided, root DB is used (not recommended)
|
||||
peers_db: "PEERS"
|
||||
|
||||
# Maximum size of database, default is 1GiB.
|
||||
# It's better specify enough space, because if environment is full,
|
||||
# storage will fail to add new records and restart and specifying larger size
|
||||
# (or online resizing with external tool) will be required.
|
||||
# See: http://www.lmdb.tech/doc/group__mdb.html#gaa2506ec8dab3d969b0e609cd82e619e5
|
||||
max_size: 1073741824
|
||||
|
||||
# Maximum number of threads/reader slots for the LMDB environment, default is 126.
|
||||
# See: http://www.lmdb.tech/doc/group__mdb.html#gae687966c24b790630be2a41573fe40e2
|
||||
max_readers: 126
|
||||
|
||||
# Set flags to use asynchronous flushes to disk.
|
||||
# See: MDB_WRITEMAP and MDB_MAPASYNC description in http://www.lmdb.tech/doc/group__mdb.html#ga32a193c6bf4d7d5c5d579e71f22e9340
|
||||
async_write: true
|
||||
|
||||
# Set MDB_NOMETASYNC flag. Omit the metadata flush on commit.
|
||||
# See: MDB_NOMETASYNC description in http://www.lmdb.tech/doc/group__mdb.html#ga32a193c6bf4d7d5c5d579e71f22e9340
|
||||
no_sync_meta: false
|
||||
```
|
||||
@@ -3,7 +3,7 @@
|
||||
This storage uses PostgreSQL-like database to store peer and arbitrary key-value data.
|
||||
|
||||
'PostgreSQL-like' means, that you can use any database which _understand_ PostgreSQL protocol
|
||||
i.e. _real_ [PostgreSQL](https://www.postgresql.org) or [CockroachDB](https://www.cockroachlabs.com).
|
||||
e.g. _real_ [PostgreSQL](https://www.postgresql.org) or [CockroachDB](https://www.cockroachlabs.com).
|
||||
|
||||
_(YugabyteDB is not recommended (at the moment), because of some problems with
|
||||
concurrent inserts while benchmarks.)_
|
||||
|
||||
Reference in New Issue
Block a user