From a6f16dcc11891c7ab1dbe3e3129cee7210da17bc 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 23ceb91cb4..3a9c5f4393 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 {