Skip to content

Commit 01c6b54

Browse files
authored
worker: add more fine-grained logging for Git index syncs (#12282)
This should be reverted once we have the data we need, but in the short term, this will be useful to decide our next step with #12281.
1 parent 346b111 commit 01c6b54

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

crates/crates_io_index/repo.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crates_io_env_vars::{required_var, required_var_parsed, var};
55
use secrecy::{ExposeSecret, SecretString};
66
use std::path::{Path, PathBuf};
77
use std::process::Command;
8+
use std::time::Instant;
89
use tempfile::TempDir;
910
use url::Url;
1011

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

286+
let fetch_start = Instant::now();
285287
self.run_command(Command::new("git").args(["fetch", "origin", "master"]))?;
288+
info!(duration = fetch_start.elapsed().as_nanos(), "Index fetched");
289+
290+
let reset_start = Instant::now();
286291
self.run_command(Command::new("git").args(["reset", "--hard", "origin/master"]))?;
292+
info!(duration = reset_start.elapsed().as_nanos(), "Index reset");
287293

288294
let head = self.head_oid()?;
289295
if head != original_head {

src/worker/environment.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ pub struct Environment {
4747
impl Environment {
4848
#[instrument(skip_all)]
4949
pub fn lock_index(&self) -> anyhow::Result<RepositoryLock<'_>> {
50+
let lock_start = Instant::now();
5051
let mut repo = self.repository.lock();
52+
info!(duration = lock_start.elapsed().as_nanos(), "Index locked");
5153

5254
if repo.is_none() {
5355
info!("Cloning index");

src/worker/jobs/index/sync.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::fs;
1111
use std::fs::File;
1212
use std::io::{ErrorKind, Write};
1313
use std::sync::Arc;
14+
use std::time::Instant;
1415
use tracing::{debug, info, instrument};
1516

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

60+
let commit_and_push_start = Instant::now();
5961
match (old, new) {
6062
(None, Some(new)) => {
6163
fs::create_dir_all(dst.parent().unwrap())?;
@@ -74,6 +76,10 @@ impl BackgroundJob for SyncToGitIndex {
7476
}
7577
_ => debug!("Skipping sync because index is up-to-date"),
7678
}
79+
info!(
80+
duration = commit_and_push_start.elapsed().as_nanos(),
81+
"Committed and pushed"
82+
);
7783

7884
Ok(())
7985
})

0 commit comments

Comments
 (0)