Skip to content

Allow Duration and byte sizes in constants for easier use.#495

Merged
hoytak merged 7 commits intomainfrom
hoytak/250916-byte-size-logging
Sep 19, 2025
Merged

Allow Duration and byte sizes in constants for easier use.#495
hoytak merged 7 commits intomainfrom
hoytak/250916-byte-size-logging

Conversation

@hoytak
Copy link
Collaborator

@hoytak hoytak commented Sep 16, 2025

  • Duration: Currently, we use a lot of _MS and _SEC suffixes in constants to denote duration. This PR allows std::time::Duration to be used directly, with values such as "10sec" or "100ms" or "1d" translated directly into std::time::Duration.

  • ByteSize: It also introduces a new utility type, ByteSize, that simply wraps a u64 but allows the user to specify "1mb" or "45gb" as the value when setting constant values. The suffixes mb, mib, kb, kib, gb, gib, b, etc. are all supported, with the default being the raw value.

Copy link
Collaborator

@seanses seanses left a comment

Choose a reason for hiding this comment

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

Looks good! Need to update the hf_xet/Cargo.lock due to new dependency. There are bytes and secs constants in other places, might as well update them to use this util.

@hoytak hoytak merged commit 610874a into main Sep 19, 2025
6 checks passed
@hoytak hoytak deleted the hoytak/250916-byte-size-logging branch September 19, 2025 17:59
seanses pushed a commit that referenced this pull request Sep 23, 2025
- Duration: Currently, we use a lot of _MS and _SEC suffixes in
constants to denote duration. This PR allows std::time::Duration to be
used directly, with values such as "10sec" or "100ms" or "1d" translated
directly into std::time::Duration.

- ByteSize: It also introduces a new utility type, ByteSize, that simply
wraps a u64 but allows the user to specify "1mb" or "45gb" as the value
when setting constant values. The suffixes mb, mib, kb, kib, gb, gib, b,
etc. are all supported, with the default being the raw value.
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.

2 participants