-
Notifications
You must be signed in to change notification settings - Fork 2.6k
chore(storage-monitor): improve free_space
calculation and cli default value
#14133
chore(storage-monitor): improve free_space
calculation and cli default value
#14133
Conversation
@@ -117,10 +117,10 @@ impl StorageMonitorService { | |||
|
|||
/// Returns free space in MB, or error if statvfs failed. | |||
fn free_space(path: &Path) -> Result<u64, Error> { | |||
Ok(fs4::available_space(path).map(|s| s / 1_000_000)?) | |||
Ok(fs4::available_space(path).map(|s| s / 1024 / 1024)?) |
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 think that the returned value was purposely returned in MB and not in MiB.
But maybe @michalkucharczyk knows better
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.
Well I made this decision basing on https://en.wikipedia.org/wiki/Megabyte being 10^6
not 1024^2
.
Feel free to change it if you really feel like we need to use MiB
(Mebibyte). But please also adjust clap
args
documentation.
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.
If we return the value in MiB then also change the docs (MB -> MiB) please
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.
also: #13466 (comment)
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.
Well, I think we should use MiB
(1024 * 1024 Byte).
This is more accurate for node consumption of storage resources.
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.
ok, for me. but please update docs/comments wherever needed.
I changed all |
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.
Please update docs/comments: MB
-> MiB
free_space
calculation and cli default value
Where? I do not know the docs. Comments have been updated all. |
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
client/storage-monitor/src/lib.rs
Outdated
#[arg(long = "db-storage-polling-period", value_name = "SECONDS", default_value_t = 5, value_parser = clap::value_parser!(u32).range(1..))] | ||
#[arg(long = "db-storage-polling-period", value_name = "SECONDS", default_value_t = 6, value_parser = clap::value_parser!(u32).range(1..))] |
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.
Why was this bumped?
client/storage-monitor/src/lib.rs
Outdated
#[arg(long = "db-storage-threshold", value_name = "MB", default_value_t = 1000)] | ||
#[arg(long = "db-storage-threshold", value_name = "MiB", default_value_t = 1000)] |
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.
When you start using base 2, maybe also use 1024
here so the default is one GiB
and not some odd mixture.
bot merge |
Waiting for commit status. |
…ult value (paritytech#14133) * chore(storage-monitor): fix free_space calculation * add `Result` type * add docs * update `polling_period` default value to `6` * Update client/storage-monitor/src/lib.rs Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> * Apply suggestions from code review --------- Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
No description provided.