Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush cached directories every so often during an add #3888

Merged
merged 1 commit into from
May 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions core/coreunix/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var log = logging.Logger("coreunix")
// how many bytes of progress to wait before sending a progress update message
const progressReaderIncrement = 1024 * 256

var liveCacheSize = uint64(256 << 10)

type Link struct {
Name, Hash string
Size uint64
Expand Down Expand Up @@ -104,6 +106,7 @@ type Adder struct {
unlocker bs.Unlocker
tempRoot *cid.Cid
Prefix *cid.Prefix
liveNodes uint64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ever being increased?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn, i knew i messed something up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}

func (adder *Adder) mfsRoot() (*mfs.Root, error) {
Expand Down Expand Up @@ -422,6 +425,19 @@ func (adder *Adder) addFile(file files.File) error {
return err
}

if adder.liveNodes >= liveCacheSize {
// TODO: A smarter cache that uses some sort of lru cache with an eviction handler
mr, err := adder.mfsRoot()
if err != nil {
return err
}
if err := mr.Flush(); err != nil {
return err
}
adder.liveNodes = 0
}
adder.liveNodes++

if file.IsDirectory() {
return adder.addDir(file)
}
Expand Down