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

Parse command start #57

Merged
merged 7 commits into from
Nov 26, 2024
Merged

Parse command start #57

merged 7 commits into from
Nov 26, 2024

Conversation

vincentdephily
Copy link
Owner

  • log
  • stats
  • filter

I think that's all the features we can do, given that I couldn't find a reliable enough heuristic to match a command start with a command end.

This only looks at the start event, as experiments in a different branch showed that matching the
end event is too unreliable.
I played around with more detailed stats, but they didn't seem that useful in the end, so for now
I'm just classifying commands as merge/clean/sync. Note that portage doesn't log all commands, so
the available data isn't as right as I thought.
This currently somewhat mirrors what qlop offers, as an MVP to get a feel of the implementation. I
initially wrote a single-pass version (droping previous table rows when encountering a command), but
the two-pass version is fast enough that `--lastmerge` is about as fast as `--last`, and offers more
flexibility.

Tentative todo:
* Allow `--lastmerge <N>`
* Move into `--from '1 command'` (simpler and more consistent)
* Optionaly ignore non-merge commands (qlop always/only does that, but it's a failible heuristic)
* Investigate `--to` support
* Move code into get_hist (DRY, and optimization opportunities)
* Test and document
* Can now specify command number, and use for both bounds
* Works for all commands, not just `log`
* More ergonomic I feel, but maybe not as discoverable
* No more surprising interaction between `--lastmerge` and `--from`
* The effective bounds are still a bit counterintuitive

I hoped to save an `open()` syscall, but gzip doesn't `impl Seek`.
* Users expect `--from=1c` to start at the last command
* Reject `0c`, accept `c`
* Add unittest, tweak inline help
Appended a non-sync emerge command to `benches/emerge.log` so that qlop finds something to
display. This is a nice illustration of how unreliable any "detect end of command" heuristics is.
It comforts me in the decision to not exactly match qlop's `--lastmerge` behavior (ignoring emerge
commands that didn't actually merge something): I value correctness over simplicity.
@vincentdephily vincentdephily merged commit 2119f41 into master Nov 26, 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