explicitly switch marksets for concurrent marking
this has very noticeable impact in initial marking time; it also allows us to get rid of the confusing ts monikers.
This commit is contained in:
parent
b6611125b6
commit
abdf4a161a
@ -18,6 +18,7 @@ type MarkSet interface {
|
||||
Mark(cid.Cid) error
|
||||
Has(cid.Cid) (bool, error)
|
||||
Close() error
|
||||
SetConcurrent()
|
||||
}
|
||||
|
||||
type MarkSetEnv interface {
|
||||
@ -28,13 +29,9 @@ type MarkSetEnv interface {
|
||||
func OpenMarkSetEnv(path string, mtype string) (MarkSetEnv, error) {
|
||||
switch mtype {
|
||||
case "bloom":
|
||||
return NewBloomMarkSetEnv(false)
|
||||
case "bloomts": // thread-safe
|
||||
return NewBloomMarkSetEnv(true)
|
||||
return NewBloomMarkSetEnv()
|
||||
case "map":
|
||||
return NewMapMarkSetEnv(false)
|
||||
case "mapts": // thread-safe
|
||||
return NewMapMarkSetEnv(true)
|
||||
return NewMapMarkSetEnv()
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown mark set type %s", mtype)
|
||||
}
|
||||
|
||||
@ -16,9 +16,7 @@ const (
|
||||
BloomFilterProbability = 0.01
|
||||
)
|
||||
|
||||
type BloomMarkSetEnv struct {
|
||||
ts bool
|
||||
}
|
||||
type BloomMarkSetEnv struct{}
|
||||
|
||||
var _ MarkSetEnv = (*BloomMarkSetEnv)(nil)
|
||||
|
||||
@ -31,8 +29,8 @@ type BloomMarkSet struct {
|
||||
|
||||
var _ MarkSet = (*BloomMarkSet)(nil)
|
||||
|
||||
func NewBloomMarkSetEnv(ts bool) (*BloomMarkSetEnv, error) {
|
||||
return &BloomMarkSetEnv{ts: ts}, nil
|
||||
func NewBloomMarkSetEnv() (*BloomMarkSetEnv, error) {
|
||||
return &BloomMarkSetEnv{}, nil
|
||||
}
|
||||
|
||||
func (e *BloomMarkSetEnv) Create(name string, sizeHint int64) (MarkSet, error) {
|
||||
@ -52,7 +50,7 @@ func (e *BloomMarkSetEnv) Create(name string, sizeHint int64) (MarkSet, error) {
|
||||
return nil, xerrors.Errorf("error creating bloom filter: %w", err)
|
||||
}
|
||||
|
||||
return &BloomMarkSet{salt: salt, bf: bf, ts: e.ts}, nil
|
||||
return &BloomMarkSet{salt: salt, bf: bf}, nil
|
||||
}
|
||||
|
||||
func (e *BloomMarkSetEnv) Close() error {
|
||||
@ -103,3 +101,7 @@ func (s *BloomMarkSet) Close() error {
|
||||
s.bf = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *BloomMarkSet) SetConcurrent() {
|
||||
s.ts = true
|
||||
}
|
||||
|
||||
@ -6,9 +6,7 @@ import (
|
||||
cid "github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
type MapMarkSetEnv struct {
|
||||
ts bool
|
||||
}
|
||||
type MapMarkSetEnv struct{}
|
||||
|
||||
var _ MarkSetEnv = (*MapMarkSetEnv)(nil)
|
||||
|
||||
@ -21,14 +19,13 @@ type MapMarkSet struct {
|
||||
|
||||
var _ MarkSet = (*MapMarkSet)(nil)
|
||||
|
||||
func NewMapMarkSetEnv(ts bool) (*MapMarkSetEnv, error) {
|
||||
return &MapMarkSetEnv{ts: ts}, nil
|
||||
func NewMapMarkSetEnv() (*MapMarkSetEnv, error) {
|
||||
return &MapMarkSetEnv{}, nil
|
||||
}
|
||||
|
||||
func (e *MapMarkSetEnv) Create(name string, sizeHint int64) (MarkSet, error) {
|
||||
return &MapMarkSet{
|
||||
set: make(map[string]struct{}, sizeHint),
|
||||
ts: e.ts,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -72,3 +69,7 @@ func (s *MapMarkSet) Close() error {
|
||||
s.set = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *MapMarkSet) SetConcurrent() {
|
||||
s.ts = true
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ const (
|
||||
type Config struct {
|
||||
// MarkSetType is the type of mark set to use.
|
||||
//
|
||||
// Only current sane value is "mapts", but we may add an option for a disk-backed
|
||||
// Only current sane value is "map", but we may add an option for a disk-backed
|
||||
// markset for memory-constrained situations.
|
||||
MarkSetType string
|
||||
|
||||
@ -1061,6 +1061,8 @@ func (s *SplitStore) beginTxnConcurrentMarking(markSet MarkSet) map[cid.Cid]stru
|
||||
s.txnLk.Lock()
|
||||
defer s.txnLk.Unlock()
|
||||
|
||||
markSet.SetConcurrent()
|
||||
|
||||
txnRefs := s.txnRefs
|
||||
s.txnRefs = nil
|
||||
s.txnMissing = make(map[cid.Cid]struct{})
|
||||
|
||||
@ -304,7 +304,7 @@ func DefaultFullNode() *FullNode {
|
||||
Splitstore: Splitstore{
|
||||
ColdStoreType: "universal",
|
||||
HotStoreType: "badger",
|
||||
MarkSetType: "mapts",
|
||||
MarkSetType: "map",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user