avoid pre-populating buffers for deployments < 32GiB memory (#19839)

This commit is contained in:
Harshavardhana
2024-05-30 04:58:12 -07:00
committed by GitHub
parent aad50579ba
commit 4af31e654b
7 changed files with 58 additions and 33 deletions

View File

@@ -91,11 +91,11 @@ func availableMemory() (available uint64) {
available = 2048 * blockSizeV2 * 2 // Default to 4 GiB when we can't find the limits.
if runtime.GOOS == "linux" {
// Useful in container mode
// Honor cgroup limits if set.
limit := cgroupMemLimit()
if limit > 0 {
// A valid value is found, return its 75%
available = (limit * 3) / 4
// A valid value is found, return its 90%
available = (limit * 9) / 10
return
}
} // for all other platforms limits are based on virtual memory.
@@ -104,8 +104,9 @@ func availableMemory() (available uint64) {
if err != nil {
return
}
// A valid value is available return its 75%
available = (memStats.Available * 3) / 4
// A valid value is available return its 90%
available = (memStats.Available * 9) / 10
return
}
@@ -129,7 +130,7 @@ func (t *apiConfig) init(cfg api.Config, setDriveCounts []int, legacy bool) {
maxSetDrives := slices.Max(setDriveCounts)
// Returns 75% of max memory allowed
maxMem := availableMemory()
maxMem := globalServerCtxt.MemLimit
// max requests per node is calculated as
// total_ram / ram_per_request