-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not leave rewritten
There was a problem hiding this comment.
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) | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gofmt
There was a problem hiding this comment.
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" { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
fa82562
to
9f8dd1b
Compare
The note is stored in the file 'diskUsage.notes'.
9f8dd1b
to
ca23b19
Compare
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@Stebalien, please see #35 |
Closing in favor of #35. |
Closes #31