Skip to content

Commit

Permalink
add more performance tracing to our storage
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Mar 7, 2024
1 parent 66bc9d0 commit 80a7894
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/storage/archive_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::storage::{compression::CompressionAlgorithm, FileRange};
use anyhow::{bail, Context as _};
use rusqlite::{Connection, OpenFlags, OptionalExtension};
use std::{fs, io, path::Path};
use tracing::instrument;

#[derive(PartialEq, Eq, Debug)]
pub(crate) struct FileInfo {
Expand Down Expand Up @@ -99,7 +100,8 @@ fn find_in_sqlite_index(conn: &Connection, search_for: &str) -> Result<Option<Fi
.context("error fetching SQLite data")
}

pub(crate) fn find_in_file<P: AsRef<Path>>(
#[instrument]
pub(crate) fn find_in_file<P: AsRef<Path> + std::fmt::Debug>(
archive_index_path: P,
search_for: &str,
) -> Result<Option<FileInfo>> {
Expand Down
9 changes: 4 additions & 5 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::{
sync::Arc,
};
use tokio::{io::AsyncWriteExt, runtime::Runtime};
use tracing::{error, info_span, instrument, trace, Instrument};
use tracing::{error, instrument, trace};

type FileRange = RangeInclusive<u64>;

Expand Down Expand Up @@ -249,6 +249,7 @@ impl AsyncStorage {
})
}

#[instrument]
pub(crate) async fn exists_in_archive(
&self,
archive_path: &str,
Expand Down Expand Up @@ -311,6 +312,7 @@ impl AsyncStorage {
Ok(blob)
}

#[instrument]
pub(super) async fn download_archive_index(
&self,
archive_path: &str,
Expand Down Expand Up @@ -361,14 +363,11 @@ impl AsyncStorage {
}
let index_filename = self
.download_archive_index(archive_path, latest_build_id)
.instrument(info_span!("download archive index"))
.await?;

let info = {
let path = path.to_owned();
spawn_blocking(move || archive_index::find_in_file(index_filename, &path))
.instrument(info_span!("find path in index"))
.await
spawn_blocking(move || archive_index::find_in_file(index_filename, &path)).await
}?
.ok_or(PathNotFoundError)?;

Expand Down

0 comments on commit 80a7894

Please sign in to comment.