generated from ipfs/ipfs-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 143
Closed
Labels
need/analysisNeeds further analysis before proceedingNeeds further analysis before proceeding
Description
When I add a folder with many small files to kubo, memory usage always spikes abnormally
- Total folder size: 400MiB
- Number of files: 10000
- Average size per file: 40KiB
I located the exception by analyzing the heap

// NewSizeSplitter returns a new size-based Splitter with the given block size.
func NewSizeSplitter(r io.Reader, size int64) Splitter {
return &sizeSplitterv2{
r: r,
size: uint32(size),
}
}
// NextBytes produces a new chunk.
func (ss *sizeSplitterv2) NextBytes() ([]byte, error) {
if ss.err != nil {
return nil, ss.err
}
full := pool.Get(int(ss.size))
n, err := io.ReadFull(ss.r, full)
switch err {
case io.ErrUnexpectedEOF:
ss.err = io.EOF
small := make([]byte, n)
copy(small, full)
pool.Put(full)
return small, nil
case nil:
return full, nil
default:
pool.Put(full)
return nil, err
}
}
// Reader returns the io.Reader associated to this Splitter.
func (ss *sizeSplitterv2) Reader() io.Reader {
return ss.r
}Q1: Will using a pool result in abnormal memory consumption when the file size is much smaller than the chunk size?
Metadata
Metadata
Assignees
Labels
need/analysisNeeds further analysis before proceedingNeeds further analysis before proceeding