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 tree and skip rows #55

Merged
merged 29 commits into from
Oct 31, 2024
Merged

Process tree and skip rows #55

merged 29 commits into from
Oct 31, 2024

Conversation

vincentdephily
Copy link
Owner

Simple feature but with a long tail of little details and fixes

We now return all processes instead of filtering, hardcode categories instead of taking a param, and
parse the parent pid. This cost just 1.5ms (with a running ebuild), and is a step towards displaying
the emerge process tree.
* Formatting/editing of commandline is delayed until display time (potentially saving a few cycles)
* Display width is now user-configurable (should be in the `predict` section only, but that's a
  refactoring for another day)
* Switched from std `Display` to our `Disp` trait

That last part is the initial motivation, as I want to be able to pass an `indent` argument.
Needs some refinements, but the basic functionality is here.
This was the original intent, and fixes an off-by-one in the error message.
Simpler code, and saves an alloc.
Better heuristics to isolate the the interesting part of the process name, and switched from regex
to plain string search.
Mainly for newlines, but let's match a bit wider to be sure.
Still not sure what the best value is, but this is enough to see the current stage.
Making this a global option, as I want to eventually use that for --first/--last skips too.
Basic indentation&skip unittest, plus some refactoring to decouple proces/current/command a bit.
There's a small time window during which `emerge` might spawn `emerge`, so it looks like we have two
running. This is a longstanding emlop bug, but it's much more noticeable now that we display the
proces hierarchy. Fix this by removing roots if their (grand)parent is also a root. Added unittest
(which prompted the previous refactorings).
By storing the header as its own member instead of a row. This simplifies the logic a bit (might
even be a micro perf win), but more importantly will simplify inserting a `skipped` row between the
header and the actual rows. Added a unittest to make sure we handle the header's width.

As a bonus, newer clippy versions don't complain about needless_range_loop, so remove the `allow`.
This makes it a bit clearer API-wise that tables can only have one header.
This means that `--first 1` now needs to read the entire log and is no longer as fast, but the
reature is worth it (and is optional via `--elipsis=n`).

I'm not too happy with the padding at the end of the skip row, and the inconsistency with the
`--last` skip row (no padding and no column align), but no need to be perfect at this stage.
Because I'm afraid that the word "elipsis" is too obscure (especially for non-native speakers), and
to make the relationship between the output and the option clearer.
@vincentdephily vincentdephily changed the title Process tree Process tree and skip rows Oct 30, 2024
This one turned out to be trivial. Removing the "hidden" count from the summary line, as it seems
redundant and less clear.
@vincentdephily vincentdephily merged commit 0bbb248 into master Oct 31, 2024
9 checks passed
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.

1 participant