Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/crates_io_index/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crates_io_env_vars::{required_var, required_var_parsed, var};
use secrecy::{ExposeSecret, SecretString};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::Instant;
use tempfile::TempDir;
use url::Url;

Expand Down Expand Up @@ -282,8 +283,13 @@ impl Repository {
pub fn reset_head(&self) -> anyhow::Result<()> {
let original_head = self.head_oid()?;

let fetch_start = Instant::now();
self.run_command(Command::new("git").args(["fetch", "origin", "master"]))?;
info!(duration = fetch_start.elapsed().as_nanos(), "Index fetched");

let reset_start = Instant::now();
self.run_command(Command::new("git").args(["reset", "--hard", "origin/master"]))?;
info!(duration = reset_start.elapsed().as_nanos(), "Index reset");

let head = self.head_oid()?;
if head != original_head {
Expand Down
2 changes: 2 additions & 0 deletions src/worker/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ pub struct Environment {
impl Environment {
#[instrument(skip_all)]
pub fn lock_index(&self) -> anyhow::Result<RepositoryLock<'_>> {
let lock_start = Instant::now();
let mut repo = self.repository.lock();
info!(duration = lock_start.elapsed().as_nanos(), "Index locked");

if repo.is_none() {
info!("Cloning index");
Expand Down
6 changes: 6 additions & 0 deletions src/worker/jobs/index/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::fs;
use std::fs::File;
use std::io::{ErrorKind, Write};
use std::sync::Arc;
use std::time::Instant;
use tracing::{debug, info, instrument};

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -56,6 +57,7 @@ impl BackgroundJob for SyncToGitIndex {
Err(error) => return Err(error.into()),
};

let commit_and_push_start = Instant::now();
match (old, new) {
(None, Some(new)) => {
fs::create_dir_all(dst.parent().unwrap())?;
Expand All @@ -74,6 +76,10 @@ impl BackgroundJob for SyncToGitIndex {
}
_ => debug!("Skipping sync because index is up-to-date"),
}
info!(
duration = commit_and_push_start.elapsed().as_nanos(),
"Committed and pushed"
);

Ok(())
})
Expand Down