Skip to content

Add a parallel implementation #26

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

Merged
merged 4 commits into from
Mar 18, 2020
Merged

Add a parallel implementation #26

merged 4 commits into from
Mar 18, 2020

Conversation

tinou98
Copy link
Contributor

@tinou98 tinou98 commented Mar 14, 2020

Added a parallel implementation so everything is faster. It's based on rayon, so it will default to the same number of parallel task as your number of CPU.
I also added a progress bar for clone and fetch

const STYLE_LOAD: &str = "{prefix:>40!.blue} {msg} {wide_bar} {percent:>3}% {eta}";
const STYLE_DONE: &str = "{prefix:>40!.blue} {wide_msg} {elapsed_precise}";
const STYLE_ERROR: &str = "{prefix:>40!.blue} {wide_msg:.red}";

Copy link
Collaborator

@jpninanjohn jpninanjohn Mar 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the alignment either completely left aligned or justified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left align : (use ^ for centering)

Suggested change
const STYLE_LOAD: &str = "{prefix:<40!.blue} {msg} {wide_bar} {percent:>3}% {eta}";
const STYLE_DONE: &str = "{prefix:<40!.blue} {wide_msg} {elapsed_precise}";
const STYLE_ERROR: &str = "{prefix:<40!.blue} {wide_msg:.red}";

Copy link
Collaborator

@jpninanjohn jpninanjohn Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const STYLE_PRELOAD: &str = "{prefix:.blue} {spinner} {wide_msg:.cyan}";
const STYLE_LOAD: &str = "{prefix:.blue} {msg} {wide_bar} {percent:>3}% {eta}";
const STYLE_DONE: &str = "{prefix:.blue} {wide_msg} {elapsed_precise}";
const STYLE_ERROR: &str = "{prefix:.blue} {wide_msg:.red}";

I would suggest not giving a size to the prefix. The paths can be of any length and will be truncated if it doesnt fit right now. Let it always print the entire path and then the message.

Copy link
Collaborator

@jpninanjohn jpninanjohn Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do this change as part of ur fork as well since you will still be working on it? Or should I make the change once I merge?

@jpninanjohn
Copy link
Collaborator

Thanks for the contribution. This is really useful. I have added some comments for some minor changes. Do let me know your thoughts.

@jpninanjohn
Copy link
Collaborator

Tagging @dineshba

@jpninanjohn
Copy link
Collaborator

jpninanjohn commented Mar 17, 2020

@tinou98 there seems to be another issue with the clone command. Previously if we try to clone the same repo to the same local path, it would fail saying the path already exists which is expected. Now it just stalls. Can you check what is happening?
Run gg clone -r [email protected]:thecasualcoder/gg.git -l some_dir twice.
Expect second time to fail ->

Cloning remotes passed as arguments
No remotes configured in conf file
thread 'main' panicked at 'Failed to clone repo [email protected]:thecasualcoder/gg.git, : Error { code: -4, klass: 3, message: "\'some_dir/gg\' exists and is not an empty directory" }', src/clone.rs:95:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

(error is not currently handled properly. But it should still fail)

On your fork it doesnt fail. It just gets stuck.

I also tried it for a repo that does not exist. It stalls.

@jpninanjohn
Copy link
Collaborator

jpninanjohn commented Mar 17, 2020

Also I think parallelism should be an option. If enabled use based on number of CPU's or user input count. If disabled fall back to single threaded execution. I worry that some systems might hang if all CPU's are used for gg.

@tinou98
Copy link
Contributor Author

tinou98 commented Mar 17, 2020

Fixed blocked issue, added control over the number of thread, setting to 1 go back to the monothreaded way. There is still an issue in monothreaded mode (-j1) that add latency before the status line is shown, I'm working on it

@jpninanjohn jpninanjohn merged commit f322901 into thecasualcoder:master Mar 18, 2020
@jpninanjohn
Copy link
Collaborator

It's Good. You can continue to work on it. Ill merge these now.

@jpninanjohn jpninanjohn linked an issue Mar 19, 2020 that may be closed by this pull request
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.

Make gg work with multithreading/parallelism
2 participants