Skip to content

Commit

Permalink
refactor func(), update memory
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr committed Apr 30, 2024
1 parent 1e1d305 commit ccc704c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
41 changes: 17 additions & 24 deletions curiosrc/ffi/sdr_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (sb *SealCalls) TreeRC(ctx context.Context, task *harmonytask.TaskID, secto

defer func() {
if err != nil {
clerr := removeDRCTrees(fspaths.Cache, "RC")
clerr := removeDRCTrees(fspaths.Cache, false)
if clerr != nil {
log.Errorw("removing tree files after TreeDRC error", "error", clerr, "exec-error", err, "sector", sector, "cache", fspaths.Cache)
}
Expand Down Expand Up @@ -272,35 +272,27 @@ func (sb *SealCalls) TreeRC(ctx context.Context, task *harmonytask.TaskID, secto
return sl, uns, nil
}

func removeDRCTrees(cache string, tree string) error {
// list files in cache
func removeDRCTrees(cache string, isDTree bool) error {
files, err := os.ReadDir(cache)
if err != nil {
return xerrors.Errorf("listing cache: %w", err)
}

switch tree {
case "D":
for _, file := range files {
if proofpaths.IsTreeDFile(file.Name()) {
err := os.Remove(filepath.Join(cache, file.Name()))
if err != nil {
return xerrors.Errorf("removing tree file: %w", err)
}
}
}
case "RC":
for _, file := range files {
if proofpaths.IsTreeRCFile(file.Name()) {
err := os.Remove(filepath.Join(cache, file.Name()))
if err != nil {
return xerrors.Errorf("removing tree file: %w", err)
}
var testFunc func(string) bool

if isDTree {
testFunc = proofpaths.IsTreeDFile
} else {
testFunc = proofpaths.IsTreeRCFile
}

for _, file := range files {
if testFunc(file.Name()) {
err := os.Remove(filepath.Join(cache, file.Name()))
if err != nil {
return xerrors.Errorf("removing tree file: %w", err)
}
}
default:
return xerrors.Errorf("incorrect input Tree type")

}
return nil
}
Expand Down Expand Up @@ -640,10 +632,11 @@ func (sb *SealCalls) PreFetch(ctx context.Context, sector storiface.SectorRef, t
}

func (sb *SealCalls) TreeD(ctx context.Context, sector storiface.SectorRef, unsealed cid.Cid, size abi.PaddedPieceSize, data io.Reader, unpaddedData bool, fspaths, pathIDs storiface.SectorPaths, release func()) error {
defer release()
var err error
defer func() {
if err != nil {
clerr := removeDRCTrees(fspaths.Cache, "D")
clerr := removeDRCTrees(fspaths.Cache, true)
if clerr != nil {
log.Errorw("removing tree files after TreeDRC error", "error", clerr, "exec-error", err, "sector", sector, "cache", fspaths.Cache)
}
Expand Down
2 changes: 1 addition & 1 deletion curiosrc/seal/task_treerc.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (t *TreeRCTask) TypeDetails() harmonytask.TaskTypeDetails {
Cost: resources.Resources{
Cpu: 1,
Gpu: 1,
Ram: 8000 << 20, // todo
Ram: 8 << 30,
Storage: t.sc.Storage(t.taskToSector, storiface.FTSealed, storiface.FTCache, ssize, storiface.PathSealing, paths.MinFreeStoragePercentage),
},
MaxFailures: 3,
Expand Down

0 comments on commit ccc704c

Please sign in to comment.