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

Introduce ProcessRefreshKind::Thread #1436

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

sigsegved
Copy link

No description provided.

@GuillaumeGomez
Copy link
Owner

A lot of extra docs to explain what this thread is about and that it only affects linux is needed too.

@sigsegved
Copy link
Author

#1432

@GuillaumeGomez
Copy link
Owner

Also: the new setting is still disabled by default.

@sigsegved
Copy link
Author

sigsegved commented Jan 29, 2025

Also: the new setting is still disabled by default.

No its not. In default we have tasks: true,. If i m not looking at the right thing can you please point me to it.?

@sigsegved
Copy link
Author

@GuillaumeGomez do you know why this task consistently fails? https://github.com/GuillaumeGomez/sysinfo/pull/1436/checks?check_run_id=36373553137

Doesnt seem to be related to my code change. its failing in rust setup.

@GuillaumeGomez
Copy link
Owner

Also: the new setting is still disabled by default.

No its not. In default we have tasks: true,. If i m not looking at the right thing can you please point me to it.?

Well, don't trust me, trust the code. Try:

let x = ProcessRefreshKind::new();
assert!(x.tasks());
Explanations

It's because you need to implement by hand the Default trait.

Please add a unit test with the code above too please.

@GuillaumeGomez do you know why this task consistently fails? https://github.com/GuillaumeGomez/sysinfo/pull/1436/checks?check_run_id=36373553137

Doesnt seem to be related to my code change. its failing in rust setup.

Yes, it's "normal". Rust's freebsd support is not great and there are often random failures depending on the nightly.

@sigsegved
Copy link
Author

sigsegved commented Jan 29, 2025

Also: the new setting is still disabled by default.

No its not. In default we have tasks: true,. If i m not looking at the right thing can you please point me to it.?

Well, don't trust me, trust the code. Try:

let x = ProcessRefreshKind::new();
assert!(x.tasks());

Explanations
It's because you need to implement by hand the Default trait.

Please add a unit test with the code above too please.

I see what you mean but ProcessRefreshKind does not have a new() fn. It has everything() and nothing(). nothing() uses the default() which means we do want tasks turned off as with other fields. everything() on the other hand turns on tasks as expected. I will update the tests to validate that using just everything() gets the tasks list.

@GuillaumeGomez do you know why this task consistently fails? https://github.com/GuillaumeGomez/sysinfo/pull/1436/checks?check_run_id=36373553137
Doesnt seem to be related to my code change. its failing in rust setup.

Yes, it's "normal". Rust's freebsd support is not great and there are often random failures depending on the nightly.

Bummer :( This shouldnt block me from merging this PR thought right?

@GuillaumeGomez
Copy link
Owner

I see what you mean but ProcessRefreshKind does not have a new() fn. It has everything() and nothing(). nothing() uses the default() which means we do want tasks turned off as with other fields. everything() on the other hand turns on tasks as expected. I will update the tests to validate that using just everything() gets the tasks list.

I actually wanted to write default(), but yes, you got the idea.

nothing should also get it. It gets the processes list, tasks are processes. So by default I'd still want them to be retrieved.

Bummer :( This shouldnt block me from merging this PR thought right?

Nah, not an issue. MacOS CI also randomly fails on test_environ. Not a blocker, it's a known issue.

@sigsegved
Copy link
Author

@GuillaumeGomez can i get an approval on this if everything looks good. This is blocking us from going into production in its current state.

@GuillaumeGomez
Copy link
Owner

@GuillaumeGomez can i get an approval on this if everything looks good. This is blocking us from going into production in its current state.

Well, neither you or your company is sponsoring my work so I have to admit it's not really one of my priorities. ^^'

@sigsegved
Copy link
Author

@GuillaumeGomez can i get an approval on this if everything looks good. This is blocking us from going into production in its current state.

Well, neither you or your company is sponsoring my work so I have to admit it's not really one of my priorities. ^^'

Going through your page, looks like my company was a previous sponsor. DM me and i would like to find out how you got sponsored before and see if I can re-engage the same path. Apologies, I'm super new to OS contributions.

/// dirs. This makes the refresh mechanism a lot slower depending on the number of tasks
/// each process has.
///
/// If you don't care about tasks information, use `ProcessRefreshKind::everything().without_thread()`
Copy link
Owner

Choose a reason for hiding this comment

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

without_tasks()


s.refresh_processes(ProcessesToUpdate::All, true);
// At this point we know the thread is visible in the system's process/tasks list.
// Lets validate a few more things:
Copy link
Owner

Choose a reason for hiding this comment

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

"Let's"

// Lets validate a few more things:
// * ProcessRefreshKind::nothing() should have thread information.
// * ProcessRefreshKind::nothing().with_tasks() should have thread information.
// * ProcessRefreshKind::nothing().without_tasks() should have thread information.
Copy link
Owner

Choose a reason for hiding this comment

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

"shouldn't", "task information"

// At this point we know the thread is visible in the system's process/tasks list.
// Lets validate a few more things:
// * ProcessRefreshKind::nothing() should have thread information.
// * ProcessRefreshKind::nothing().with_tasks() should have thread information.
Copy link
Owner

Choose a reason for hiding this comment

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

"task information"

// * ProcessRefreshKind::nothing().with_tasks() should have thread information.
// * ProcessRefreshKind::nothing().without_tasks() should have thread information.
// * ProcessRefreshKind::everything() should have thread information.
// * ProcessRefreshKind::everything() should have thread information.
Copy link
Owner

Choose a reason for hiding this comment

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

It's the same line as before.

// * ProcessRefreshKind::nothing() should have thread information.
// * ProcessRefreshKind::nothing().with_tasks() should have thread information.
// * ProcessRefreshKind::nothing().without_tasks() should have thread information.
// * ProcessRefreshKind::everything() should have thread information.
Copy link
Owner

Choose a reason for hiding this comment

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

"task information"

Comment on lines +1941 to +1943
/// Creates a new `ProcessRefreshKind` with every refresh set to `false`, except for `tasks`
/// This is because by default, [`Process`] was fetching all tasks and we want to keep this
/// behavior.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
/// Creates a new `ProcessRefreshKind` with every refresh set to `false`, except for `tasks`
/// This is because by default, [`Process`] was fetching all tasks and we want to keep this
/// behavior.
/// Creates a new `ProcessRefreshKind` with every refresh set to `false`, except for `tasks`.
/// By default, we want to list all processes and tasks are considered processes on their own
/// in linux so we still fetch them by default. However, the processes information are not
/// refreshed.

Comment on lines +1919 to +1922
/// Default implementation for [`ProcessRefreshKind`].
/// Sets everything to default values except for `tasks` which is set to `true`.
/// This is because by default, a [`Process`] was fetching all tasks and we want to keep this
/// behavior.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
/// Default implementation for [`ProcessRefreshKind`].
/// Sets everything to default values except for `tasks` which is set to `true`.
/// This is because by default, a [`Process`] was fetching all tasks and we want to keep this
/// behavior.
/// Creates a new `ProcessRefreshKind` with every refresh set to `false`, except for `tasks`.
/// By default, we want to list all processes and tasks are considered processes on their own
/// in linux so we still fetch them by default. However, the processes information are not
/// refreshed.

@GuillaumeGomez
Copy link
Owner

I think this is the last review round before merging (if I didn't forget anything hopefully).

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