write anything beyond 4k to be written in 4k pages (#19269)

we were prematurely not writing 4k pages while we
could have due to the fact that most buffers would
be multiples of 4k upto some number and there shall
be some remainder.

We only need to write the remainder without O_DIRECT.
This commit is contained in:
Harshavardhana
2024-03-15 12:27:59 -07:00
committed by GitHub
parent d2373d5d6c
commit c201d8bda9
2 changed files with 31 additions and 24 deletions

View File

@@ -54,8 +54,6 @@ import (
const (
nullVersionID = "null"
// Largest streams threshold per shard.
largestFileThreshold = 64 * humanize.MiByte // Optimized for HDDs
// Small file threshold below which data accompanies metadata from storage layer.
smallFileThreshold = 128 * humanize.KiByte // Optimized for NVMe/SSDs
@@ -2113,11 +2111,11 @@ func (s *xlStorage) writeAllDirect(ctx context.Context, filePath string, fileSiz
var bufp *[]byte
switch {
case fileSize > 0 && fileSize >= largestFileThreshold:
case fileSize > 0 && fileSize >= xioutil.BlockSizeReallyLarge:
// use a larger 4MiB buffer for a really large streams.
bufp = xioutil.ODirectPoolXLarge.Get().(*[]byte)
defer xioutil.ODirectPoolXLarge.Put(bufp)
case fileSize <= smallFileThreshold:
case fileSize <= xioutil.BlockSizeSmall:
bufp = xioutil.ODirectPoolSmall.Get().(*[]byte)
defer xioutil.ODirectPoolSmall.Put(bufp)
default: