From c9ab6dc532c902354343af4747a6573314d2f0e1 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 12 May 2020 20:18:57 +0300 Subject: [PATCH] lib/fs: do not use mmap for 32-bit arches by default, since they cannot map files bigger than 4GB in RAM --- lib/fs/reader_at.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/fs/reader_at.go b/lib/fs/reader_at.go index f94f1ba05..a9e6f3dff 100644 --- a/lib/fs/reader_at.go +++ b/lib/fs/reader_at.go @@ -10,7 +10,10 @@ import ( "golang.org/x/sys/unix" ) -var disableMmap = flag.Bool("fs.disableMmap", false, "Whether to use pread() instead of mmap() for reading data files") +var disableMmap = flag.Bool("fs.disableMmap", is32BitPtr, "Whether to use pread() instead of mmap() for reading data files. "+ + "By default mmap() is used for 64-bit arches and pread() is used for 32-bit arches, since they cannot data files bigger than 2^32 bytes in memory") + +const is32BitPtr = (^uintptr(0) >> 32) == 0 // MustReadAtCloser is rand-access read interface. type MustReadAtCloser interface {