mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-09 22:51:02 +00:00
Don't automatically freeze the results of RowSegment ops
I think when this code was written, I thought "freeze" would be really cheap. It's not actually that cheap. As a result, freezing things preemptively when it may be that nothing ever tries to write to them anyway is possibly disadvantageous, to the tune of being roughly 20% of a sample profile we were shown. Instead, we don't mark the components "writable", so if anything wants to write to them, it'll end up freezing itself new copies of their bitmaps later. But in practice that probably doesn't happen.
This commit is contained in:
parent
0bba9c81e8
commit
6abe7dc12f
1 changed files with 15 additions and 25 deletions
40
row.go
40
row.go
|
|
@ -574,13 +574,11 @@ func (s *rowSegment) IntersectionCount(other *rowSegment) uint64 {
|
|||
// Intersect returns the itersection of s and other.
|
||||
func (s *rowSegment) Intersect(other *rowSegment) *rowSegment {
|
||||
data := s.data.Intersect(other.data)
|
||||
data = data.Freeze()
|
||||
|
||||
return &rowSegment{
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
writable: true,
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -591,13 +589,11 @@ func (s *rowSegment) Union(others ...*rowSegment) *rowSegment {
|
|||
datas[i] = other.data
|
||||
}
|
||||
data := s.data.Union(datas...)
|
||||
data.Freeze()
|
||||
|
||||
return &rowSegment{
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
writable: true,
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -635,26 +631,22 @@ func (s *rowSegment) Difference(others ...*rowSegment) *rowSegment {
|
|||
datas[i] = other.data
|
||||
}
|
||||
data := s.data.Difference(datas...)
|
||||
data.Freeze()
|
||||
|
||||
return &rowSegment{
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
writable: true,
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
}
|
||||
}
|
||||
|
||||
// Xor returns the xor of s and other.
|
||||
func (s *rowSegment) Xor(other *rowSegment) *rowSegment {
|
||||
data := s.data.Xor(other.data)
|
||||
data = data.Freeze()
|
||||
|
||||
return &rowSegment{
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
writable: true,
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -666,13 +658,11 @@ func (s *rowSegment) Shift() (*rowSegment, error) {
|
|||
if err != nil {
|
||||
return nil, errors.Wrap(err, "shifting roaring data")
|
||||
}
|
||||
data = data.Freeze()
|
||||
|
||||
return &rowSegment{
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
writable: true,
|
||||
data: data,
|
||||
shard: s.shard,
|
||||
n: data.Count(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue