Skip to content

Peak memory usage measurements may be inaccurate or missing on Linux #161

Closed

Description

@sharkdp

Thank you for providing an independent benchmark of Python type checkers!

If I am understanding the code here correctly, you are using a (10 ms) polling strategy to measure peak RSS on Linux. This approach is prone to errors, since fast commands may not receive any measurements at all. And even for slow commands, the last 0 - 10 ms in peak RSS will be missing. Presumably, the end of the program is where most type checkers have their highest memory usage, so it would be good to include those last 10 ms.

I think you could use wait4 to get accurate peak RSS measurements on Linux, which would probably also result in a simplification of the code.

Disclaimer: I work on ty (but this issue is not about something that would affect ty in a specific way)

Activity

  1. lolpack commented on Nov 3, 2026

    @lolpack
    Owner

    Good find! Feel free to put up a PR for the change along with the before-and-after benchmarks. I will fix it eventually, but happy to review a PR in the meantime.

  2. sharkdp commented on Nov 3, 2026

    @sharkdp
    ContributorAuthor

    Thank you for the prompt reply. I opened a PR with a fix in #165. The results show that this isn't just a theoretical problem. Peak RSS can be ~20% higher for fast-running type checkers now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions