mirror of
https://github.com/minio/minio.git
synced 2025-03-29 08:43:40 -04:00
fix: crash on 32bit systems during pre-allocation (#19225)
This commit is contained in:
parent
934f6cabf6
commit
2cc4997d24
@ -92,15 +92,15 @@ func newErasureServerPools(ctx context.Context, endpointServerPools EndpointServ
|
|||||||
n = 2048
|
n = 2048
|
||||||
}
|
}
|
||||||
|
|
||||||
if globalIsCICD {
|
|
||||||
n = 256 // 256MiB for CI/CD environments is sufficient
|
|
||||||
}
|
|
||||||
|
|
||||||
// Avoid allocating more than half of the available memory
|
// Avoid allocating more than half of the available memory
|
||||||
if maxN := availableMemory() / (blockSizeV2 * 2); n > maxN {
|
if maxN := availableMemory() / (blockSizeV2 * 2); n > maxN {
|
||||||
n = maxN
|
n = maxN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if globalIsCICD || strconv.IntSize == 32 {
|
||||||
|
n = 256 // 256MiB for CI/CD environments is sufficient or on 32bit platforms.
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize byte pool once for all sets, bpool size is set to
|
// Initialize byte pool once for all sets, bpool size is set to
|
||||||
// setCount * setDriveCount with each memory upto blockSizeV2.
|
// setCount * setDriveCount with each memory upto blockSizeV2.
|
||||||
globalBytePoolCap = bpool.NewBytePoolCap(n, blockSizeV2, blockSizeV2*2)
|
globalBytePoolCap = bpool.NewBytePoolCap(n, blockSizeV2, blockSizeV2*2)
|
||||||
|
@ -87,14 +87,14 @@ func cgroupMemLimit() (limit uint64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func availableMemory() (available uint64) {
|
func availableMemory() (available uint64) {
|
||||||
available = 8 << 30 // Default to 8 GiB when we can't find the limits.
|
available = 2048 * blockSizeV2 * 2 // Default to 4 GiB when we can't find the limits.
|
||||||
|
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
// Useful in container mode
|
// Useful in container mode
|
||||||
limit := cgroupMemLimit()
|
limit := cgroupMemLimit()
|
||||||
if limit > 0 {
|
if limit > 0 {
|
||||||
// A valid value is found
|
// A valid value is found, return its 75%
|
||||||
available = limit
|
available = (limit * 3) / 4
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} // for all other platforms limits are based on virtual memory.
|
} // for all other platforms limits are based on virtual memory.
|
||||||
@ -103,7 +103,8 @@ func availableMemory() (available uint64) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
available = memStats.Available / 2
|
// A valid value is available return its 75%
|
||||||
|
available = (memStats.Available * 3) / 4
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +133,7 @@ func (t *apiConfig) init(cfg api.Config, setDriveCounts []int) {
|
|||||||
|
|
||||||
var apiRequestsMaxPerNode int
|
var apiRequestsMaxPerNode int
|
||||||
if cfg.RequestsMax <= 0 {
|
if cfg.RequestsMax <= 0 {
|
||||||
|
// Returns 75% of max memory allowed
|
||||||
maxMem := availableMemory()
|
maxMem := availableMemory()
|
||||||
|
|
||||||
// max requests per node is calculated as
|
// max requests per node is calculated as
|
||||||
|
Loading…
x
Reference in New Issue
Block a user