MCPcopy
hub / github.com/kopia/kopia / releaseChunk

Method releaseChunk

internal/gather/gather_write_buffer_chunk.go:121–143  ·  view source on GitHub ↗
(s []byte)

Source from the content-addressed store, hash-verified

119}
120
121func (a *chunkAllocator) releaseChunk(s []byte) {
122 if cap(s) != a.chunkSize {
123 return
124 }
125
126 a.mu.Lock()
127 defer a.mu.Unlock()
128
129 if a.activeChunks != nil {
130 ptr := uintptr(unsafe.Pointer(unsafe.SliceData(s))) //nolint:gosec
131 delete(a.activeChunks, ptr)
132 }
133
134 a.freed++
135
136 if len(a.freeList) < a.maxFreeListSize {
137 a.freeList = append(a.freeList, s[:0])
138 }
139
140 if len(a.freeList) > a.freeListHighWaterMark {
141 a.freeListHighWaterMark = len(a.freeList)
142 }
143}
144
145func (a *chunkAllocator) dumpStats(ctx context.Context, prefix string) {
146 a.mu.Lock()

Callers 3

TestWriteBufferChunkFunction · 0.95
CloseMethod · 0.80
ResetMethod · 0.80

Calls 2

LockMethod · 0.65
UnlockMethod · 0.65

Tested by 1

TestWriteBufferChunkFunction · 0.76