mirror of
https://github.com/minio/minio.git
synced 2025-04-25 04:33:20 -04:00
Avoid allocs for MRF on-disk header (#18425)
This commit is contained in:
parent
54721b7c7b
commit
9569a85cee
@ -3187,12 +3187,16 @@ func (p *ReplicationPool) queueMRFSave(entry MRFReplicateEntry) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ReplicationPool) persistToDrive(ctx context.Context, v MRFReplicateEntries, data []byte) {
|
func (p *ReplicationPool) persistToDrive(ctx context.Context, v MRFReplicateEntries) {
|
||||||
newReader := func() io.ReadCloser {
|
newReader := func() io.ReadCloser {
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
go func() {
|
go func() {
|
||||||
|
// Initialize MRF meta header.
|
||||||
|
var data [4]byte
|
||||||
|
binary.LittleEndian.PutUint16(data[0:2], mrfMetaFormat)
|
||||||
|
binary.LittleEndian.PutUint16(data[2:4], mrfMetaVersion)
|
||||||
mw := msgp.NewWriter(w)
|
mw := msgp.NewWriter(w)
|
||||||
n, err := mw.Write(data)
|
n, err := mw.Write(data[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.CloseWithError(err)
|
w.CloseWithError(err)
|
||||||
return
|
return
|
||||||
@ -3230,15 +3234,10 @@ func (p *ReplicationPool) saveMRFEntries(ctx context.Context, entries map[string
|
|||||||
|
|
||||||
v := MRFReplicateEntries{
|
v := MRFReplicateEntries{
|
||||||
Entries: entries,
|
Entries: entries,
|
||||||
Version: mrfMetaVersionV1,
|
Version: mrfMetaVersion,
|
||||||
}
|
}
|
||||||
data := make([]byte, 4, v.Msgsize()+4)
|
|
||||||
|
|
||||||
// Initialize the resync meta header.
|
p.persistToDrive(ctx, v)
|
||||||
binary.LittleEndian.PutUint16(data[0:2], mrfMetaFormat)
|
|
||||||
binary.LittleEndian.PutUint16(data[2:4], mrfMetaVersion)
|
|
||||||
|
|
||||||
p.persistToDrive(ctx, v, data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load mrf entries from disk
|
// load mrf entries from disk
|
||||||
|
Loading…
x
Reference in New Issue
Block a user