Skip to content

Commit 7ac8b10

Browse files
downloader: docs on MMAP for data-files r/w and experiments with bufio (#10074)
Pros: - it allows to not pre-alloc files: #8688 - it allows to not "sig-bus" when no space left on disk (return user-friendly error). see: #8500 - but DB will be MMAP anyway and may get "sig-bus" FYI: - seems no perf difference (but i tested only on cloud drives) - erigon will anyway open it as mmap Cons: - i did implemented `fsync` for mmap ( anacrolix/torrent#755 ) - probably will need implement it for bufio: anacrolix/torrent#937 - no zero-copy: more `alloc` memory will be holded by APP (PageCache starvation). I see 2x mem usage (at `--torrent.download.slots=500` 20gb vs 40gb) - i see "10K threads exchaused" error earlier (on `--torrent.download.slots=500`). - what else?
1 parent 382f881 commit 7ac8b10

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
File renamed without changes.

erigon-lib/downloader/downloader.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,7 +2568,18 @@ func openClient(ctx context.Context, dbDir, snapDir string, cfg *torrent.ClientC
25682568
if err != nil {
25692569
return nil, nil, nil, nil, fmt.Errorf("torrentcfg.NewMdbxPieceCompletion: %w", err)
25702570
}
2571+
2572+
//Reasons why using MMAP instead of files-API:
2573+
// - i see "10K threads exchaused" error earlier (on `--torrent.download.slots=500` and `pd-ssd`)
2574+
// - "sig-bus" at disk-full - may happen anyway, because DB is mmap
2575+
// - MMAP - means less GC pressure, more zero-copy
2576+
// - MMAP files are pre-allocated - which is not cool, but: 1. we can live with it 2. maybe can just resize MMAP in future
2577+
// See also: https://github.com/ledgerwatch/erigon/pull/10074
25712578
m = storage.NewMMapWithCompletion(snapDir, c)
2579+
//m = storage.NewFileOpts(storage.NewFileClientOpts{
2580+
// ClientBaseDir: snapDir,
2581+
// PieceCompletion: c,
2582+
//})
25722583
cfg.DefaultStorage = m
25732584

25742585
torrentClient, err = torrent.NewClient(cfg)

0 commit comments

Comments
 (0)