-
Notifications
You must be signed in to change notification settings - Fork 180
Use the right sized byte array for large indexes #301
Conversation
fileutil/mmap_windows.go
Outdated
return (*[1 << 32]byte)(unsafe.Pointer(addr))[:sz], nil | ||
} | ||
|
||
if sz <= 1<<34 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not always use this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are allocating 16G everytime? Whether or not we are using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that's an allocation?
12a45e6
to
89b0e10
Compare
@@ -35,7 +35,7 @@ func mmap(f *os.File, sz int) ([]byte, error) { | |||
return nil, os.NewSyscallError("CloseHandle", err) | |||
} | |||
|
|||
return (*[1 << 30]byte)(unsafe.Pointer(addr))[:sz], nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sz
is just size
? Can we name it like that? (maybe just for master)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I have stupid question. I have never used mmap
before, but... why don't we cast to just [sz]byte
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same thing and tried it but casting to an array requires a constant for the array size as this is evaluated at compile time
- return (*[sz]byte)(unsafe.Pointer(addr))[:sz], nil = non-constant array bound
89b0e10
to
220d269
Compare
Fixes: prometheus/prometheus#3957 Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
220d269
to
fb65e3d
Compare
👍 tsdb needs another revendor then |
Fixes: prometheus/prometheus#3957
Not happy with this, suggestions welcome. @Bplotka
This change is