Skip to content

Commit

Permalink
initial review comments
Browse files Browse the repository at this point in the history
(still exploring the code)
  • Loading branch information
Stebalien committed Jul 9, 2021
1 parent abdf4a1 commit 5ed35cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions blockstore/splitstore/markset_bloom.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func (s *BloomMarkSet) saltedKey(cid cid.Cid) []byte {
key := make([]byte, len(s.salt)+len(hash))
n := copy(key, s.salt)
copy(key[n:], hash)
// FYI, you probably don't need a cryptographic hash function here given that we're salting
// anyways.
// You could use https://golang.org/pkg/hash/maphash/
// (probably)
// (if it's a perf issue)
rehash := sha256.Sum256(key)
return rehash[:]
}
Expand Down
17 changes: 17 additions & 0 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ func (s *SplitStore) Has(cid cid.Cid) (bool, error) {
return true, nil
}

// Didn't we need to somehow ressurect everything under this in case we decide to GC? Or are
// we handling that in a followup patch.
return s.cold.Has(cid)
}

Expand Down Expand Up @@ -618,13 +620,27 @@ func (s *SplitStore) trackTxnRefMany(cids []cid.Cid) error {
return nil
}

// This could get _real_ slow (many minutes to hours) and will block tipset verification. Can we do this lazily and/or force
// the GC thread to handle this?
//
// I.e., take a lock to make sure GC is paused, then stick this in a "to traverse" queue. Then, when
// GC "resumes", it first checks that queue.

// transactionally protect a reference by walking the object and marking.
// concurrent markings are short circuited by checking the markset.
func (s *SplitStore) doTxnProtect(root cid.Cid, batch map[cid.Cid]struct{}) error {
// Note: cold objects are deleted heaviest first, so the consituents of an object
// cannot be deleted before the object itself.
err := s.walkObjectIncomplete(root, cid.NewSet(),
func(c cid.Cid) error {
// Let's make sure we _completely_ match vm.Copy. We don't need this _now_,
// but should try to not to introduce inconsistencies.

if root.Prefix().MhType == 0 {
// identity cid, skip
return errStopWalk
}

if isFilCommitment(c) {
return errStopWalk
}
Expand Down Expand Up @@ -1282,6 +1298,7 @@ func (s *SplitStore) checkClosing() error {
return nil
}

// This is very dangerious and could go horribly wrong if we have anything else with a structure that matches a block header.
func (s *SplitStore) isOldBlockHeader(c cid.Cid, epoch abi.ChainEpoch) (isOldBlock bool, err error) {
if c.Prefix().Codec != cid.DagCBOR {
return false, nil
Expand Down

0 comments on commit 5ed35cd

Please sign in to comment.