290 points · by signa11 · 5y ago · 97 comments
I appreciate the author wanting users to discover a program running amok and producing a bunch of threads (anecdote: I've never seen it happen), but there's a bunch of ways to solve it from a UX perspective:
* make threads collapsed by default
* add a column showing the number of threads a process has
* add the threads toggle to the bottom bar for easy discovery
* add a prefix to all threads, e.g. [THREAD]
All of these are a lot more obvious than the color green.
The authors story of having users ask him why processes are green is simply an indication that the user interface is hard to understand.
I feel like that's the crux of it. If I'm reading htop right I'm at ~140 tasks* and ~1000 threads.
The itch.io app that is hanging out in my system tray is currently sitting at ~200 threads by itself.
It's not helpful or educational to have pages of identically named threads especially when everything is only getting more multithreaded.
*and that's for my Cinnamon desktop, three firefox windows, thunderbird, steam, itch, a terminal and htop, lord knows if I was actually doing something with my computer.
...just so that _I_ can know that you know what you're talking about, can you elaborate on what that obvious mistake (which I clearly know about) is?
Dropping the joke - I assume it's that threads share memory in some way (so that the total consumed is not the sum of each consumption), but a. how and why, and b. why isn't it trivial for htop to represent that "correctly"?
Saw this article, installed htop, ran it - all in pre coffee morning fog
OMG A dozen firefox threads each using 10%! ....
Even in my 10% early morning function I realised, but I get your point.
This is a lesson to all of us, that we might have very good reasons, but there's still a chance to be wrong about things.
But it worked about two thirds of the times :-)
Seems like that's easier to do than a thought about the actual substance of the blog post. Or being grateful that there is such a fantastic tool around, that there is a profound philosophy behind it, or that the original author shared it with us with some pretty good arguments.
But sure, let's keep discussing why shift-H needs to be made into a more prominent entry in the htop option screen.
The default UI did not tell me if the threads had 'run amok'. There aren't enough lines on the display to tell whether a process with 10 threads on a normal day is now running 50.
So like you said, I had to turn off threads, then turn on the thread count column (which I never would have found without a search engine/stack overflow).
FYI the column exists already, but it's not enabled by deault. It's called NLWP, which I assume is short for Number of LightWeight Processes.
As for my own UI suggestions, I would hide threads by default, and stop displaying anything in all the columns of a thread where it's impossible for the cell to be different to its parent.
Maybe in tree mode, have all of a process's threads grouped under an expandable [threads] pseudo-process as well.
If so I'd like to learn about the technique
I've seen it in production. But the simple solution is to cap the number of threads to a reasonable value (ulimits, Kubernetes Pod Security Policy) and add observability for thread count.
Threading is much more prolific today than it was 15 years ago. Multicore processors are the norm today and there are plenty of great libraries out there which make threading easier, and less error prone than it used to be. It is common today for language libraries to keep thread pools available for executing small concurrent operations. In such a case, knowing what thread was consuming resources probably wouldn't help much in tracking down the issue.
So yeah, I agree with your suggestions. I think they make a lot of sense today. In fact, I bet of the original author were creating htop in 2020, they would make these changes.
That's because there isn't a easy way in htop to discover that.
htop is great, I've used it for a decade, but I didn't know you could hide the threads (Shift+H) until I read this today.
A "View options" / "Advanced" menu item on the bottom bar would help discover these option exists.
I also pressed some key, and some things turned purple, and there's no indication what view is shown, what the purple colour means, and what to do to turn it off.
I think there's a lot to learn in the design philosophy of giving the power to users by default, but if you don't give your users the tools to learn this power they're going to have to ask questions if they want to yield it
I'd appreciate it if more developers considered 'discoverability' as a core part of their design philosophy. I think the author is close, but when you need to ask someone/search 'why is this green?' that's enough of a barrier that most people won't bother asking (or it'll be a small enough issue that they don't consciously notice it).
There's even a generally accepted solution for explaining semantic colours, a legend. Might be nice to have one down with the F-keys.
For example, I missed that they use capital and non-capital letters: H (shift+h) toggles the threads, but i sat there opening/closing the help screen by pressing just h. Careful reading of the help screen would have prevented that. As none of the same lowercase/capital letters are next to each other, it is easy to miss.
To be quite honest, I don't know any of the keys not mentioned in F-list at the bottom other than space and I think k, everything was always through Setup Menu.
Plus, after looking through all the options, I couldn't find an option to hide threads by default. EDIT: later I realized that pressing Shift+H automatically sets the option "Hide userland process threads", and I overlooked it because I was looking for a disabled option. So htop was actually smarter than I was giving it credit for. However, it definitely wouldn't hurt to mention Shift+H on the help screen :)
Left column, 10th item.
CLI is trending amongst dev's again, and we should take a lesson by htop how to design a good user interface.
Part of why the shell is gaining is that UIs are invariably becoming less efficient with rampant use of React and node for native apps.
I did not say node is slow.
I don't know if that's as true as "GUIs are now unfashionable to devs". It is hard to blame them since GUIs have regressed so significantly ever since the iPhone.
Did it ever stopped being useful?
I just hope it doesn't swing back too far the other way as it has before (I've been around long enough to have seen the cycle previously!). I'm a big fan for command line, scriptable, tools and plain text pipe-able output, and have been since being introduced to pipes & redirection all those decades ago, but we need to avoid the holier-than-thou thing that seems to develop when our old timer ways get the lime-light for a while. It only serves to put people off learning that they are great tools for many jobs and definitively the right ones for a some.
Today, even some of those tools are embracing CLIs.
htop has a GUI, not a CLI. Some people call it a "TUI" but in terms of UX and program architecture it's a lot closer to a GUI than a CLI.
They do different things differently, but they achieve great results in their own ways.
The mc file manager or ranger more than stands the comparison against graphical file managers.
Another example is 'apt-get' vs aptitude. The earlier is inherently scriptable. The latter needs you to start the program, input a few keys, exit.
fdisk is another terminal program that's not command line.
In an ideal world the concept of TUI would not exist.
no, ncurses is an implementation kit for screen-oriented TUIs. CLI, TUI, GUI are all separate things..
For me the design philosophy worked quite well. I learned so much about my system just by using it and trying to understand all of its output. And I am still learning after years of using it.
I actually like to just sit and watch it sometimes, it's fascinating to me how much a computer does at all times, even when it is idle.
While thinking about it, I'd like to inject htop in misbehaving kubernetes containers. Does anyone know if there is a static compile available somewhere or something.
The ephemeral debug container can contain htop while the application container doesn't. This way minimal application containers aren't complicating debugging when something goes wrong :)
Having the ability to ruin my OS (all three floppy disks of it) made learning easier. Being protected from root level commands doesn't suit me on my personal machines. "Mistakes are proof you're trying".
How can you ever learn any responsibility without any power, great or otherwise?
Software, as I think of it, is a way to expose the "general purpose" nature of computers to users. Good software teaches users how to access that nature. Like a good teacher, that leading should be subtle and gentle and have the end goal of user empowerment.
You can delete ~/.config/htop/htoprc to reset it to default settings in case it's a misconfiguration.
Shots fired at GNOME