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

Store note on accuracy of initial disk usage calculation in diskUsage notes #33

Closed
wants to merge 2 commits into from

Conversation

kevina
Copy link
Contributor

@kevina kevina commented Mar 11, 2018

Closes #31

@ghost ghost assigned kevina Mar 11, 2018
@ghost ghost added the status/in-progress In progress label Mar 11, 2018
@kevina kevina requested review from Stebalien and hsanjuan March 12, 2018 16:12
Copy link
Contributor

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

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

Thanks, this is nice

README.md Outdated
@@ -60,6 +60,8 @@ datastore is not open), with the right disk usage value in size. I.e., in the da
3919232394 .
$ echo -n "3919232394" > diskUsage.cache

The accuracy of the initial disk usage calculation is stores in the file `diskUsage.notes`, this file is for reference only and is
Copy link
Contributor

Choose a reason for hiding this comment

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

stored

convert.go Outdated
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query"
"github.com/jbenet/go-os-rename"
"gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore"
Copy link
Contributor

Choose a reason for hiding this comment

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

should not leave rewritten

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops. Sorry.

flatfs_test.go Outdated
@@ -660,7 +669,7 @@ func testDiskUsageEstimation(dirFunc mkShardFunc, t *testing.T) {
if err != nil {
t.Fatal(err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

gofmt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought I did. Sorry.

if err != nil {
t.Fatal(err)
}
if string(d) != "initial-exact\n" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use constant instead of literal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a test, so I want to make sure it has the right value.

Copy link
Contributor

Choose a reason for hiding this comment

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

But the right value is and will always be the one defined by the constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, unless its accidentally modified in which case this test will fail to alert you of that fact. If it was intentional, then the test case (and the README) should also be modified.

if err != nil {
t.Fatal(err)
}
if string(d) != "initial-approximate\n" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a test, so I want to make sure it has the right value.

README.md Outdated
@@ -60,6 +60,8 @@ datastore is not open), with the right disk usage value in size. I.e., in the da
3919232394 .
$ echo -n "3919232394" > diskUsage.cache

The accuracy of the initial disk usage calculation is stores in the file `diskUsage.notes`, this file is for reference only and is
currently not used in any other way.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's explain what each of the three possible values mean, from a user perspective it's may not be clear what initial-timed-out actually signals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

@kevina kevina force-pushed the kevina/diskusage-notes branch from fa82562 to 9f8dd1b Compare March 12, 2018 16:51
The note is stored in the file 'diskUsage.notes'.
@kevina kevina force-pushed the kevina/diskusage-notes branch from 9f8dd1b to ca23b19 Compare March 12, 2018 16:55
@kevina kevina requested a review from hsanjuan March 12, 2018 21:27
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Looks fine to me but I'd like to consider putting everything in one file (see my comment).

if err != nil {
return err
}
if time.Now().After(deadline) {
if accuracy == timedoutA {
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want to print warnings for any inaccuracy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe. My code does not change the behavior of @hsanjuan code.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. We can always change this later.

@@ -35,6 +35,9 @@ var (
// DiskUsageFile is the name of the file to cache the size of the
// datastore in disk
DiskUsageFile = "diskUsage.cache"
// DiskUsageNodes stores notes about the accuracy of the size of
// the diskusage calculation
DiskUsageNotes = "diskUsage.notes"
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to put this in the same file? Or just have one JSON/CBOR file with all the information (significantly more flexible)? That would also allow it to be atomic.

This would also allow us to keep track of the disk size accuracy if we crash. We could record the fact that we're currently running while running. If we start up and see that we didn't correct the state, we can adjust the accuracy to approximate (or something else).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did it this way for simplicity. It has the advantage of not having to read the accuracy data once written, but I have no problem doing something more sophisticated.

Copy link
Member

Choose a reason for hiding this comment

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

My motivation is really atomicity. It allows us to atomically store the repo size and it's accuracy (and allows us to deal with the inaccurate repo size on crash case). However, I don't really feel strongly any which way.

@kevina
Copy link
Contributor Author

kevina commented Mar 23, 2018

Any reason not to put this in the same file?

@Stebalien, please see #35

@kevina
Copy link
Contributor Author

kevina commented Mar 28, 2018

Closing in favor of #35.

@kevina kevina closed this Mar 28, 2018
@ghost ghost removed the status/in-progress In progress label Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants