Skip to content
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

internal_stats: init, report current memory consumption on linux and mac #4554

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

widlarizer
Copy link
Collaborator

To find out static memory usage right after RTLIL generation and at other points in the flow, currently the best practice is to dump and reload and inspect peak memory usage. This PR adds the experimental devstat command that prints in a JSON format the current memory usage. It is intended to be expanded further for information about the efficiency of RTLIL object representation and anything else that's relevant to yosys developers but not users.

On linux, yosys inspects its /proc/self/status file. This may not be present on some Linux distributions, but it should be handled gracefully should that file not exist.

On macOS, I use task_info

  • human readable format when -json isn't used

@widlarizer widlarizer changed the title devstat: init, report current memory consumption on linux and mac internal_stats: init, report current memory consumption on linux and mac Sep 3, 2024
@widlarizer widlarizer marked this pull request as ready for review September 3, 2024 17:25
@widlarizer widlarizer requested a review from povik September 3, 2024 17:25
Copy link
Member

@povik povik left a comment

Choose a reason for hiding this comment

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

Tested on macOS, we can get this into shape as we go, it's useful already

log("{\n");
log(" \"creator\": %s,\n", json11::Json(yosys_version_str).dump().c_str());
std::stringstream invocation;
std::copy(args.begin(), args.end(), std::ostream_iterator<std::string>(invocation, " "));
Copy link
Member

Choose a reason for hiding this comment

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

I think it's best to serialize that as a list

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just copy pasted that from the json backend

void help() override
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
log("\n"); // TODO
Copy link
Member

Choose a reason for hiding this comment

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

Help missing, not something we should let into a release

Copy link
Member

Choose a reason for hiding this comment

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

TIL empty help messages causes docs to fail (granted it is technically a warning, but warnings are errors in our ReadtheDocs setup)
/home/docs/checkouts/readthedocs.org/user_builds/yosys/checkouts/latest/docs/source/cmd/internal_stats.rst:21: WARNING: Literal block expected; none found. [docutils]

@povik povik merged commit 68fbca8 into main Sep 3, 2024
36 checks passed
@mmicko mmicko deleted the emil/devstat branch September 6, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants