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

Process sorting in tree mode #683

Closed
whatbh opened this issue Feb 27, 2022 · 4 comments
Closed

Process sorting in tree mode #683

whatbh opened this issue Feb 27, 2022 · 4 comments
Labels
bug Something isn't working the way that is expected.

Comments

@whatbh
Copy link

whatbh commented Feb 27, 2022

Describe the bug

In tree mode, the process is sorted ascending by PID by default. Is this expected or there's a good reason for it? I'd glad if it remains being sorted by CPU. Secondly, even if clicking on "CPU" column title to sort by CPU, the process does not appear to be sort by CPU. Some processes that were using enormous amount of CPU now disappear from the order. I don't even know what's the logic behind sorting in tree mode.

What operating system/architecture are you using?

Macos Catalina

What terminal are you using bottom on?

Macos default Terminal

What version are you on?

bottom 0.6.8

How did you install bottom?

brew install bottom

How can we reproduce this?

Switch to tree mode by hitting t or directly entering tree mode by running btm -T

What is the actual behaviour?

When entering tree mode, process is sorted by PID. When manually sort by CPU, it does not sort by CPU by some mysterious logic.

What is the expected behaviour?

Process should be sorted by CPU by default in tree mode. And the order must somehow logical, at least the most consuming processes don't get out of the top.

@whatbh whatbh added the bug Something isn't working the way that is expected. label Feb 27, 2022
@ClementTsang
Copy link
Owner

ClementTsang commented Feb 27, 2022

Both of these are currently expected behaviour. When you go into tree mode, the current behaviour is to put it into PID mode first. And if you sort by, say, CPU, it sorts on a per-level basis.

So here, since the top-level chrome process is 0.3%, it's put before picom, which is 0.2%, and firefox, which is also 0.2%. However, inside that level the chrome process has child processes that are greater than 0.3%, but since they are of a different level, they don't go above the original chrome process.

image

However, regarding the first part (the default sorting order), I was actually planning on changing this since I didn't really like it either (see #571, though that's been stalled due to IRL reasons like drowning under schoolwork). This was honestly just arbitrary behaviour I programmed in way back when I originally implemented the feature.

As for the second part, this is the same behaviour as htop IIRC, which is what I originally copied when implementing this feature. Maybe I'll think of something else in the future for alternative optional behaviour, but for now, that's staying as is.

But since both of these are expected behaviour, I'll be closing this for now.

@whatbh
Copy link
Author

whatbh commented Feb 27, 2022

Thanks for your explanation, I get it.
Now, I'm not sure if it'd be more convenient (at least to some, like me) to let the parent process somehow "(reverse) inherit" the properties of child process. For example I have these 2 perl script which hogged up all my CPU, but in tree mode they're in the bottom since they're spawn by login shell. Then I'm thinking if you can make this an option (like a commandline argument): the parent process carry child properties, like login 0.0% (perl 50.0%) and sort them according to "carried properties" form the child process.
If you think this is reasonable I will open a "feature request". @ClementTsang
Normal:
Screen Shot 2022-02-27 at 9 28 00 AM
Tree mode:
Screen Shot 2022-02-27 at 9 39 45 AM

@ClementTsang
Copy link
Owner

Yeah, that's kinda what I was thinking - I already do something similar if the user collapses the entry, so maybe an option where all child usage propagates up to the parents by default might be nice.

@whatbh
Copy link
Author

whatbh commented Feb 27, 2022

Thanks for letting me know. I created a feature request regarding this matter #684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working the way that is expected.
Projects
None yet
Development

No branches or pull requests

2 participants