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

Populate the DAG on git branchless init #308

Closed
arxanas opened this issue Mar 24, 2022 · 0 comments · Fixed by #686
Closed

Populate the DAG on git branchless init #308

arxanas opened this issue Mar 24, 2022 · 0 comments · Fixed by #686
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@arxanas
Copy link
Owner

arxanas commented Mar 24, 2022

If you run git branchless init and then git smartlog in a big repository like https://github.com/mozilla/gecko-dev, it takes ~20 seconds to build the initial internal DAG. It would be best to do this during the init step, since that's the time you would expect any heavy-lifting operations to be carried out.

We just need to add a call to sync the DAG in the init function here:

/// Initialize `git-branchless` in the current repo.
#[instrument]
pub fn init(
effects: &Effects,
git_run_info: &GitRunInfo,
main_branch_name: Option<&str>,
) -> eyre::Result<()> {

The call is to Dag::open_and_sync, and looks like this:

let references_snapshot = repo.get_references_snapshot()?;
let event_replayer = EventReplayer::from_event_log_db(effects, &repo, &event_log_db)?;
let event_cursor = event_replayer.make_default_cursor();
let mut dag = Dag::open_and_sync(
effects,
&repo,
&event_replayer,
event_cursor,
&references_snapshot,
)?;

To test this:

  1. Clone mozilla/gecko-dev locally.
  2. Delete any existing DAG like this: rm -r /path/to/gecko-dev/.git/branchless/dag/
  3. Run cargo run -- -C /path/to/gecko-dev init and confirm that it produces a progress meter like this:
Updating commit graph (5.1s)

and that it terminates after a few seconds.

It would also be cool if you could make the message say "Initializing commit graph" instead of "Updating commit graph" if this is the first time the DAG is being initialized, but it's not important. (That would be a more involved change.)

@arxanas arxanas added enhancement New feature or request good first issue Good for newcomers labels Mar 24, 2022
melko added a commit to melko/git-branchless that referenced this issue Nov 22, 2022
DAG initialization can be quite slow for big repos, so first execution
of a command can take some time because of this.
Populate DAG during init to speedup subsequent commands execution.

Fix arxanas#308
melko added a commit to melko/git-branchless that referenced this issue Nov 22, 2022
DAG initialization can be quite slow for big repos, so first execution
of a command can take some time because of this.
Populate DAG during init to speedup subsequent commands execution.

Fix arxanas#308
melko added a commit to melko/git-branchless that referenced this issue Nov 26, 2022
DAG initialization can be quite slow for big repos, so first execution
of a command can take some time because of this.
Populate DAG during init to speedup subsequent commands execution.

Fix arxanas#308
arxanas added a commit that referenced this issue Nov 29, 2022
DAG initialization can be quite slow for big repos, so first execution
of a command can take some time because of this.
Populate DAG during init to speedup subsequent commands execution.

Fix #308

Co-authored-by: Waleed Khan <me@waleedkhan.name>
arxanas added a commit that referenced this issue Dec 1, 2022
DAG initialization can be quite slow for big repos, so first execution
of a command can take some time because of this.
Populate DAG during init to speedup subsequent commands execution.

Fix #308

Co-authored-by: Waleed Khan <me@waleedkhan.name>
arxanas added a commit that referenced this issue Dec 1, 2022
DAG initialization can be quite slow for big repos, so first execution
of a command can take some time because of this.
Populate DAG during init to speedup subsequent commands execution.

Fix #308

Co-authored-by: Waleed Khan <me@waleedkhan.name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant