-
Notifications
You must be signed in to change notification settings - Fork 286
https://github.com/o2sh/onefetch/issues/310 #341
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
Conversation
Merge pull request #337 from HallerPatrick/master
Merge o2sh/onefetch master into fork
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome! Thanks for your hard work!
Very impressive @HallerPatrick, I tried running your branch on a few repos, everything seems to work fine except for the linux repo where I got a:
if failed here: However, the response time has increased quite a bit, still on the linux repo, we went from: $ time onefetch_master >
real 0m15,742s
user 0m21,599s
sys 0m3,985s to: $ time onefetch >
real 0m28,633s
user 0m33,951s
sys 0m1,097s By the way, the |
|
…nd name due to invalid utf8
Alright also fixed the Signature utf-8 problem with using
I also tested this now with Hyperfine (which seems to be a good tool) and had the same results. Its interesting that using git sys calls seem to be much faster than using git2. Maybe commands like I definitely wanted to dig deeper into this.
I would probably move this to another pull requests to keep the diff small and separation of purpose. If that's okay. |
It's the before (linux repo):
now:
By the way, if you remove
|
@o2sh Yeah , I think we reached a little bit of a dead end with git2. With the sys call we just used the logs to parse the commits, but with git2 we can only use the actual refs/commit, which is much more expensive. IMO, we are dealing with the linux repo with a edge case. With something like $ time onefetch
3.69s user 1.86s system 212% cpu 2.605 total
$ time ../../Projects/onefetch/target/release/onefetch
3.84s user 1.34s system 200% cpu 2.586 total But in the end it is your decision if that is enough or if performance is more important to you. We would have to wait for git2 bindings to logs. |
what about this part:
I think it can be removed without issue: hence getting us pretty close to git sys calls RT. We can start from there and look for other optimizations afterwards - if possible. |
It looks like the commit list is already sorted, at least are creation date and last commit the same with the removed line. So yeah I removed it |
- Merge git_utils with repo into a single file - Move get_repo_size_field into info file - Remove blocking dependency with Git binary from onefetch
I took the liberty to make some minor changes e99c56f |
The cleaner the code the happier I am. Is anything now holding us back from merging? |
We'll wait for @spenserblack to finish his review. On my side, I'm very happy with this PR. Indeed, even if we loose in performance, I still believe that getting rid of the git sys calls - we still have one call in |
I am on your side.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll wait for @spenserblack to finish his review.
Sorry, I didn't realize that you were still waiting for me.
This looks great, @HallerPatrick, thanks for all your help!
Once again, I left a suggested change that shouldn't change the logic at all, just the code style. Optional if you want to implement it.
Overall, LGTM 👍
src/onefetch/repo.rs
Outdated
if let Ok(commit) = repo.find_commit(r) { | ||
if no_merges { | ||
let parents = commit.parents().len(); | ||
if parents > 1 { | ||
return None; | ||
} | ||
} | ||
Some(commit) | ||
} else { | ||
None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is basically converting a Result
to an Option
that has been filtered, I think this can be simplified with Result::ok
and Option::filter
.
Something like
repo.find_commit(r).ok().filter(|commit| !(no_merges && commit.parents().len() > 1))
Once again, didn't test the above code, though 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright worked directly.
Resolve Issue #310 and #338
Please review, because this includes a lot of changes. Sorry for that.