Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Allocate in 16MB chunks, make creation of memory maps always aligned to 16MB chunks

j.laycock4257582db5e7
diff --git a/weed/storage/memory_map/memory_map_windows.go b/weed/storage/memory_map/memory_map_windows.go
index 055aeacc5b..c5deef84a6 100644
--- a/weed/storage/memory_map/memory_map_windows.go
+++ b/weed/storage/memory_map/memory_map_windows.go
@@ -38,19 +38,26 @@ var (
var system_info, err = getSystemInfo()
-var chunk_size = uint64(system_info.dwAllocationGranularity) * 512
+var chunk_size = uint64(system_info.dwAllocationGranularity) * 256
func (mMap *MemoryMap) CreateMemoryMap(file *os.File, maxlength uint64) {
- maxlength_high := uint32(maxlength >> 32)
- maxlength_low := uint32(maxlength & 0xFFFFFFFF)
+ chunks := (maxlength / chunk_size)
+ if chunks*chunk_size < maxlength {
+ chunks = chunks + 1
+ }
+
+ alignedMaxLength := chunks * chunk_size
+
+ maxlength_high := uint32(alignedMaxLength >> 32)
+ maxlength_low := uint32(alignedMaxLength & 0xFFFFFFFF)
file_memory_map_handle, err := windows.CreateFileMapping(windows.Handle(file.Fd()), nil, windows.PAGE_READWRITE, maxlength_high, maxlength_low, nil)
if err == nil {
mMap.File = file
mMap.file_memory_map_handle = uintptr(file_memory_map_handle)
- mMap.write_map_views = make([]MemoryBuffer, 0, maxlength/chunk_size)
- mMap.max_length = maxlength
+ mMap.write_map_views = make([]MemoryBuffer, 0, alignedMaxLength/chunk_size)
+ mMap.max_length = alignedMaxLength
mMap.End_of_file = -1
}
}