Skip to content

sys::resource update max_rss accessor doc to reflect the unit per platform #2333

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

Merged
merged 1 commit into from
Mar 16, 2024

Conversation

devnexen
Copy link
Contributor

on Apple's devices. this field returns the value in byte. close #2331

#[cfg(not(apple_targets))]
return self.0.ru_maxrss;
#[cfg(apple_targets)]
return self.0.ru_maxrss >> 10;
Copy link
Member

Choose a reason for hiding this comment

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

What about updating the doc on apple_targets rather than tweaking the code so that we can be more resilient to this kind of changes:

    /// The resident set size at its peak,
    #[cfg_attr(apple_targets, doc = " in bytes.")]
    #[cfg_attr(not(apple_targets), doc = "in kilobytes.")]
    pub fn max_rss(&self) -> c_long {
        self.0.ru_maxrss

@devnexen devnexen force-pushed the get_resource_macos branch from 3277ffc to 599550b Compare March 16, 2024 07:47
@@ -293,7 +293,9 @@ impl Usage {
TimeVal::from(self.0.ru_stime)
}

/// The resident set size at its peak, in kilobytes.
/// /// The resident set size at its peak,
Copy link
Member

Choose a reason for hiding this comment

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

Seems to be redundant:

Suggested change
/// /// The resident set size at its peak,
/// The resident set size at its peak,

/// The resident set size at its peak, in kilobytes.
/// /// The resident set size at its peak,
#[cfg_attr(apple_targets, doc = " in bytes.")]
#[cfg_attr(not(apple_targets), doc = "in kilobytes.")]
Copy link
Member

@SteveLauC SteveLauC Mar 16, 2024

Choose a reason for hiding this comment

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

Nit: might be better to have a space here:

Suggested change
#[cfg_attr(not(apple_targets), doc = "in kilobytes.")]
#[cfg_attr(not(apple_targets), doc = " in kilobytes.")]

@devnexen devnexen force-pushed the get_resource_macos branch from 599550b to 748a0d2 Compare March 16, 2024 07:55
Copy link
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

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

Thanks! Are you willing to update the PR title since Nix's merge queue uses squash merge, the PR title will be used as the commit message

@devnexen devnexen changed the title sys::resource: making rusage's ru_maxrss return Kb always. @devnexen sys::resource update max_rss accessor doc to reflect the unit per platform Mar 16, 2024
@devnexen devnexen changed the title @devnexen sys::resource update max_rss accessor doc to reflect the unit per platform sys::resource update max_rss accessor doc to reflect the unit per platform Mar 16, 2024
@SteveLauC SteveLauC added this pull request to the merge queue Mar 16, 2024
Merged via the queue into nix-rust:master with commit 36e0248 Mar 16, 2024
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.

ru_maxrss in the result of getrusage is in bytes on macOS
2 participants