Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Place a ceiling for initial capacity allocated for bytes.Buffer #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion new.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
var NewSegmentBufferNumResultsBump int = 100
var NewSegmentBufferNumResultsFactor float64 = 1.0
var NewSegmentBufferAvgBytesPerDocFactor float64 = 1.0
var MaxSegmentBufferInitialSize int = 10 * 1024 * 1024 // 10MB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking, does it make it sense it make this as a config option in bleve? If we have that, perhaps it would make things a bit more flexible and accommodative based on the use case of application, like the application can run some iterations with different values and set it as a config which works the best for their use case which need not be the optimal value for other use cases.


// ValidateDocFields can be set by applications to perform additional checks
// on fields in a document being added to a new segment, by default it does
Expand Down Expand Up @@ -61,7 +62,11 @@ func (*ZapPlugin) newWithChunkMode(results []index.Document,
NewSegmentBufferNumResultsFactor)
estimateNumResults := int(float64(len(results)+NewSegmentBufferNumResultsBump) *
NewSegmentBufferAvgBytesPerDocFactor)
br.Grow(estimateAvgBytesPerDoc * estimateNumResults)
sizeEstimate := estimateAvgBytesPerDoc * estimateNumResults
if sizeEstimate > MaxSegmentBufferInitialSize {
sizeEstimate = MaxSegmentBufferInitialSize
}
br.Grow(sizeEstimate)
}

s.results = results
Expand Down