From 6abe7dc12fb049efc3be489c96b6a2c880edf70d Mon Sep 17 00:00:00 2001 From: Seebs Date: Thu, 16 Apr 2020 17:05:55 -0500 Subject: [PATCH] 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. --- row.go | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/row.go b/row.go index f1c67123c..8d2c121d2 100644 --- a/row.go +++ b/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 }