-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add concurrency to update command #112
Conversation
Thank you for working on this. I'd prefer if the updating code was transformed into a |
…s instead of `JoinSet`
I've changed it up to a |
I feel like doing this without removing/cloning the elements from the btreemap would require not using tokio's multithreading (since that requires futures to be You could also do it by returning a type from |
HTTP requests are IO bound and I think that a single concurrent thread can handle many of them well enough, especially since we don't want more than a handful of concurrent downloads anyways. Also note that it is possible to use both together, as in
I've thought of doing that as well, but given the simplistic nature of the data I feel this would be too much boilerplate compared to just cloning and overwriting the entire pin. Looking at the code some more, I increasingly think this should be a If I remember correctly, the |
I'll work on doing a single threaded solution now and see the difference for my small scale use case 👍
I am currently sort of doing both of these approaches with a
I don't think that is true since it is implemented with a |
Changed error handling slightly to ignore missing pins
I've updated the PR to use a single-threaded concurrent implementation now with no cloning/removing of pins. I switched to a On my PC just by messing about with updating some repositories with 3-8 pins I notice no difference between the performance of the multi-threaded and single-threaded impls. |
Co-authored-by: piegames <[email protected]>
In the most recent commit I added a progress "UI" that much more clearly indicates what is being updated. Let me know what you think! pretty_updating.mov |
Oh, this is really neat! Would it be possible to encode the information in color plus some changing text? Also, how does this fall back when not in a terminal? |
I could add a arg to the pin writer to add a status string as well, maybe it could be turned into a enum later but that might be overkill for now.
It doesn't use |
status_text.mov |
Just the minimum, as in the software should still be usable without spamming control sequences when its output is piped to a file or a pager for some reason |
I'll make it write to stderr and keep the diffs to stdout then so people don't get control sequence messes if they do it. |
Nevermind, I also made them just fully ignore the control codes: not_terminal.mov |
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.
Getting close, thanks for your work!
The colors in the animation, are they still readable with a light terminal background?
white_theme.movIt looks pretty good but ideally the dark/light green would get swapped, though that would probably not be worth the additional code needed for terminal theme detection. |
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.
This looks awesome! If you want to tidy up the commit history before I merge, do it now
I think I'm pretty satisfied with it already so you are welcome to merge! |
.pins | ||
.iter_mut() | ||
.enumerate() | ||
.filter(|(_, (name, _))| opts.names.is_empty() || valid_names.contains(name)) |
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.
Shouldn't the enumerate come after the filter for correct indexing?
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.
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.
Would you mind reviewing #78 to make sure I didn't break the animation?
Closes #108
This PR is pretty minimal in what it changes, I'd be happy to also work on other features such as adding a max amount of concurrent updates at once or having a flag to revert back to single threaded mode if its deemed desirable. A progress spinner/bar could also be nice to add later.