chore(storage-monitor): improve free_space calculation and cli default value#14133
Conversation
| /// 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.
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.
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.
If we return the value in MiB then also change the docs (MB -> MiB) please
There was a problem hiding this comment.
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.
ok, for me. but please update docs/comments wherever needed.
|
I changed all |
michalkucharczyk
left a comment
There was a problem hiding this comment.
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>
| #[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..))] |
| #[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.
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.