Skip to content

Commit

Permalink
Experimental market migration memory reduction (#260)
Browse files Browse the repository at this point in the history
* 1000x less memory held during market migration

* Review Response

---------

Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com>
  • Loading branch information
ZenGround0 and ZenGround0 committed Apr 22, 2024
1 parent e0cffac commit 2ba2d25
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion builtin/v13/migration/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,22 @@ func (m *marketMigrator) migrateProviderSectorsAndStatesFromScratch(ctx context.
return cid.Undef, cid.Undef, xerrors.Errorf("failed to load proposals array: %w", err)
}

proposalsSize := proposalsArr.Length()

var oldState market12.DealState
var newState market13.DealState

var cnt int
err = oldStateArray.ForEach(&oldState, func(i int64) error {
// Refresh proposals array periodically to avoid holding onto all ~10GB of memory
// throughout whole migration.
// This has limited impact on caching speedups because the access pattern is sequential.
cnt += 1
if proposalsSize > 0 && cnt%(int(proposalsSize/1000)) == 0 {
proposalsArr, err = adt.AsArray(ctxStore, proposals, market12.ProposalsAmtBitwidth)
if err != nil {
return xerrors.Errorf("failed to load proposals array: %w", err)
}
}
deal := abi.DealID(i)

newState.SlashEpoch = oldState.SlashEpoch
Expand Down

0 comments on commit 2ba2d25

Please sign in to comment.