From 6f97cc7522ebb2adc56c4bdb278e80bf7b9d3656 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Mon, 24 May 2021 03:41:16 -0700 Subject: Only use 1/8 of the system RAM On systems with high memory pressure, using half of the entire RAM for hashing can result in fscrypt getting OOM killed. Signed-off-by: Joe Richey --- actions/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/config.go b/actions/config.go index b848d92..fb0e3c1 100644 --- a/actions/config.go +++ b/actions/config.go @@ -242,7 +242,7 @@ func getHashingCosts(target time.Duration) (*metadata.HashingCosts, error) { // memoryBytesLimit returns the maximum amount of memory we will use for // passphrase hashing. This will never be more than a reasonable maximum (for -// compatibility) or half the available system RAM. +// compatibility) or an 8th the available system RAM. func memoryBytesLimit() int64 { // The sysinfo syscall only fails if given a bad address var info unix.Sysinfo_t @@ -250,7 +250,7 @@ func memoryBytesLimit() int64 { util.NeverError(err) totalRAMBytes := int64(info.Totalram) - return util.MinInt64(totalRAMBytes/2, maxMemoryBytes) + return util.MinInt64(totalRAMBytes/8, maxMemoryBytes) } // betweenCosts returns a cost between a and b. Specifically, it returns the -- cgit v1.2.3