aboutsummaryrefslogtreecommitdiff
path: root/actions/config.go
diff options
context:
space:
mode:
authorJoe Richey <joerichey@google.com>2021-05-24 03:41:16 -0700
committerJoe Richey <joerichey@google.com>2021-05-24 03:41:16 -0700
commit6f97cc7522ebb2adc56c4bdb278e80bf7b9d3656 (patch)
tree3ccbdca1b321377eee975889bc1a5b6fcbca3829 /actions/config.go
parente479779a7f39e66d3f76673f18308906e817be02 (diff)
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 <joerichey@google.com>
Diffstat (limited to 'actions/config.go')
-rw-r--r--actions/config.go4
1 files changed, 2 insertions, 2 deletions
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