Skip to content

Commit

Permalink
Fix hang with crazy map allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenGround0 committed Dec 26, 2024
1 parent 8613cf8 commit bb6d93a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions blockstore/splitstore/markset_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func NewMapMarkSetEnv(path string) (*MapMarkSetEnv, error) {

func (e *MapMarkSetEnv) New(name string, sizeHint int64) (MarkSet, error) {
path := filepath.Join(e.path, name)
// Limit map size to 1k if sizeHint exceeds this value
// This prevents accidental hanging when sizeHint is too large
if sizeHint > 1000 {
sizeHint = 1000
}
return &MapMarkSet{
set: make(map[string]struct{}, sizeHint),
path: path,
Expand Down
5 changes: 1 addition & 4 deletions blockstore/splitstore/splitstore_warmup.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ func (s *SplitStore) doWarmup2(curTs *types.TipSet) error {
log.Infow("warmup starting")

epoch := curTs.Height()
count := new(int64)
// Empirically taken from December 2024
*count = MarkSetEstimate
s.markSetSize = *count + *count>>2 // overestimate a bit
s.markSetSize = MarkSetEstimate
err := s.ds.Put(s.ctx, markSetSizeKey, int64ToBytes(s.markSetSize))
if err != nil {
log.Warnf("error saving mark set size: %s", err)
Expand Down

0 comments on commit bb6d93a

Please sign in to comment.