mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 14:00:51 +00:00
perf: add several #[instrument]
s
This commit is contained in:
parent
7875656354
commit
018bb88ec6
12 changed files with 26 additions and 1 deletions
|
@ -62,7 +62,7 @@ pub mod watchman {
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tracing::info;
|
use tracing::{info, instrument};
|
||||||
use watchman_client::prelude::{
|
use watchman_client::prelude::{
|
||||||
Clock as InnerClock, ClockSpec, NameOnly, QueryRequestCommon, QueryResult,
|
Clock as InnerClock, ClockSpec, NameOnly, QueryRequestCommon, QueryResult,
|
||||||
};
|
};
|
||||||
|
@ -142,6 +142,7 @@ pub mod watchman {
|
||||||
/// running, this will start it and have it crawl the working
|
/// running, this will start it and have it crawl the working
|
||||||
/// copy to build up its in-memory representation of the
|
/// copy to build up its in-memory representation of the
|
||||||
/// filesystem, which may take some time.
|
/// filesystem, which may take some time.
|
||||||
|
#[instrument]
|
||||||
pub async fn init(working_copy_path: &Path) -> Result<Self, Error> {
|
pub async fn init(working_copy_path: &Path) -> Result<Self, Error> {
|
||||||
info!("Initializing Watchman filesystem monitor...");
|
info!("Initializing Watchman filesystem monitor...");
|
||||||
let connector = watchman_client::Connector::new();
|
let connector = watchman_client::Connector::new();
|
||||||
|
@ -165,6 +166,7 @@ pub mod watchman {
|
||||||
///
|
///
|
||||||
/// The returned list of paths is absolute. If it is `None`, then the
|
/// The returned list of paths is absolute. If it is `None`, then the
|
||||||
/// caller must crawl the entire working copy themselves.
|
/// caller must crawl the entire working copy themselves.
|
||||||
|
#[instrument(skip(self))]
|
||||||
pub async fn query_changed_files(
|
pub async fn query_changed_files(
|
||||||
&self,
|
&self,
|
||||||
previous_clock: Option<Clock>,
|
previous_clock: Option<Clock>,
|
||||||
|
|
|
@ -17,6 +17,7 @@ use std::path::PathBuf;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use backoff::{retry, ExponentialBackoff};
|
use backoff::{retry, ExponentialBackoff};
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
pub struct FileLock {
|
pub struct FileLock {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
|
@ -64,6 +65,7 @@ impl FileLock {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for FileLock {
|
impl Drop for FileLock {
|
||||||
|
#[instrument(skip_all)]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
std::fs::remove_file(&self.path).expect("failed to delete lock file");
|
std::fs::remove_file(&self.path).expect("failed to delete lock file");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ use std::fs::File;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use rustix::fs::FlockOperation;
|
use rustix::fs::FlockOperation;
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
pub struct FileLock {
|
pub struct FileLock {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
|
@ -48,6 +49,7 @@ impl FileLock {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for FileLock {
|
impl Drop for FileLock {
|
||||||
|
#[instrument(skip_all)]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Removing the file isn't strictly necessary, but reduces confusion.
|
// Removing the file isn't strictly necessary, but reduces confusion.
|
||||||
_ = std::fs::remove_file(&self.path);
|
_ = std::fs::remove_file(&self.path);
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::repo_path::{RepoPath, RepoPathComponent};
|
use crate::repo_path::{RepoPath, RepoPathComponent};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
|
@ -126,6 +128,7 @@ pub struct PrefixMatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrefixMatcher {
|
impl PrefixMatcher {
|
||||||
|
#[instrument]
|
||||||
pub fn new(prefixes: &[RepoPath]) -> Self {
|
pub fn new(prefixes: &[RepoPath]) -> Self {
|
||||||
let mut tree = RepoPathTree::new();
|
let mut tree = RepoPathTree::new();
|
||||||
for prefix in prefixes {
|
for prefix in prefixes {
|
||||||
|
|
|
@ -303,6 +303,7 @@ impl ReadonlyRepo {
|
||||||
self.loader().load_at_head(user_settings)
|
self.loader().load_at_head(user_settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
pub fn reload_at(&self, operation: &Operation) -> Result<Arc<ReadonlyRepo>, RepoLoaderError> {
|
pub fn reload_at(&self, operation: &Operation) -> Result<Arc<ReadonlyRepo>, RepoLoaderError> {
|
||||||
self.loader().load_at(operation)
|
self.loader().load_at(operation)
|
||||||
}
|
}
|
||||||
|
|
|
@ -574,6 +574,7 @@ impl TreeState {
|
||||||
|
|
||||||
#[cfg(feature = "watchman")]
|
#[cfg(feature = "watchman")]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
#[instrument(skip(self))]
|
||||||
pub async fn query_watchman(
|
pub async fn query_watchman(
|
||||||
&self,
|
&self,
|
||||||
) -> Result<(watchman::Clock, Option<Vec<PathBuf>>), TreeStateError> {
|
) -> Result<(watchman::Clock, Option<Vec<PathBuf>>), TreeStateError> {
|
||||||
|
@ -704,6 +705,7 @@ impl TreeState {
|
||||||
Ok(has_changes || fsmonitor_clock_needs_save)
|
Ok(has_changes || fsmonitor_clock_needs_save)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
fn make_fsmonitor_matcher(
|
fn make_fsmonitor_matcher(
|
||||||
&mut self,
|
&mut self,
|
||||||
fsmonitor_kind: Option<FsmonitorKind>,
|
fsmonitor_kind: Option<FsmonitorKind>,
|
||||||
|
@ -1311,6 +1313,7 @@ impl WorkingCopy {
|
||||||
&self.checkout_state().workspace_id
|
&self.checkout_state().workspace_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
fn tree_state(&self) -> Result<&TreeState, TreeStateError> {
|
fn tree_state(&self) -> Result<&TreeState, TreeStateError> {
|
||||||
self.tree_state.get_or_try_init(|| {
|
self.tree_state.get_or_try_init(|| {
|
||||||
TreeState::load(
|
TreeState::load(
|
||||||
|
@ -1338,6 +1341,7 @@ impl WorkingCopy {
|
||||||
Ok(self.tree_state()?.sparse_patterns())
|
Ok(self.tree_state()?.sparse_patterns())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
fn save(&mut self) {
|
fn save(&mut self) {
|
||||||
self.write_proto(crate::protos::working_copy::Checkout {
|
self.write_proto(crate::protos::working_copy::Checkout {
|
||||||
operation_id: self.operation_id().to_bytes(),
|
operation_id: self.operation_id().to_bytes(),
|
||||||
|
@ -1468,6 +1472,7 @@ impl LockedWorkingCopy<'_> {
|
||||||
Ok(stats)
|
Ok(stats)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
pub fn finish(mut self, operation_id: OperationId) -> Result<(), TreeStateError> {
|
pub fn finish(mut self, operation_id: OperationId) -> Result<(), TreeStateError> {
|
||||||
assert!(self.tree_state_dirty || &self.old_tree_id == self.wc.current_tree_id()?);
|
assert!(self.tree_state_dirty || &self.old_tree_id == self.wc.current_tree_id()?);
|
||||||
if self.tree_state_dirty {
|
if self.tree_state_dirty {
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::sync::{Mutex, Once};
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
/// Contains the callbacks passed to currently-live [`CleanupGuard`]s
|
/// Contains the callbacks passed to currently-live [`CleanupGuard`]s
|
||||||
static LIVE_GUARDS: Lazy<Mutex<GuardTable>> = Lazy::new(|| Mutex::new(Slab::new()));
|
static LIVE_GUARDS: Lazy<Mutex<GuardTable>> = Lazy::new(|| Mutex::new(Slab::new()));
|
||||||
|
@ -36,6 +37,7 @@ impl CleanupGuard {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for CleanupGuard {
|
impl Drop for CleanupGuard {
|
||||||
|
#[instrument(skip_all)]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let guards = &mut *LIVE_GUARDS.lock().unwrap();
|
let guards = &mut *LIVE_GUARDS.lock().unwrap();
|
||||||
let f = guards.remove(self.slot);
|
let f = guards.remove(self.slot);
|
||||||
|
|
|
@ -914,6 +914,7 @@ impl WorkspaceCommandHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
pub fn base_ignores(&self) -> Arc<GitIgnoreFile> {
|
pub fn base_ignores(&self) -> Arc<GitIgnoreFile> {
|
||||||
fn xdg_config_home() -> Result<PathBuf, VarError> {
|
fn xdg_config_home() -> Result<PathBuf, VarError> {
|
||||||
if let Ok(x) = std::env::var("XDG_CONFIG_HOME") {
|
if let Ok(x) = std::env::var("XDG_CONFIG_HOME") {
|
||||||
|
@ -1540,6 +1541,7 @@ pub enum StaleWorkingCopyError {
|
||||||
UnrelatedOperation,
|
UnrelatedOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
pub fn check_stale_working_copy(
|
pub fn check_stale_working_copy(
|
||||||
locked_wc: &LockedWorkingCopy,
|
locked_wc: &LockedWorkingCopy,
|
||||||
wc_commit: &Commit,
|
wc_commit: &Commit,
|
||||||
|
|
|
@ -3673,6 +3673,7 @@ pub fn default_app() -> Command {
|
||||||
Commands::augment_subcommands(Args::command())
|
Commands::augment_subcommands(Args::command())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), CommandError> {
|
pub fn run_command(ui: &mut Ui, command_helper: &CommandHelper) -> Result<(), CommandError> {
|
||||||
let derived_subcommands: Commands =
|
let derived_subcommands: Commands =
|
||||||
Commands::from_arg_matches(command_helper.matches()).unwrap();
|
Commands::from_arg_matches(command_helper.matches()).unwrap();
|
||||||
|
|
|
@ -85,6 +85,7 @@ impl LayeredConfigs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
pub fn read_user_config(&mut self) -> Result<(), ConfigError> {
|
pub fn read_user_config(&mut self) -> Result<(), ConfigError> {
|
||||||
self.user = existing_config_path()?
|
self.user = existing_config_path()?
|
||||||
.map(|path| read_config_path(&path))
|
.map(|path| read_config_path(&path))
|
||||||
|
|
|
@ -28,6 +28,7 @@ use jj_lib::repo_path::RepoPath;
|
||||||
use jj_lib::settings::UserSettings;
|
use jj_lib::settings::UserSettings;
|
||||||
use jj_lib::tree::{Tree, TreeDiffIterator};
|
use jj_lib::tree::{Tree, TreeDiffIterator};
|
||||||
use jj_lib::{diff, files, rewrite, tree};
|
use jj_lib::{diff, files, rewrite, tree};
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::cli_util::{CommandError, WorkspaceCommandHelper};
|
use crate::cli_util::{CommandError, WorkspaceCommandHelper};
|
||||||
use crate::formatter::Formatter;
|
use crate::formatter::Formatter;
|
||||||
|
@ -671,6 +672,7 @@ pub fn show_git_diff(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
pub fn show_diff_summary(
|
pub fn show_diff_summary(
|
||||||
formatter: &mut dyn Formatter,
|
formatter: &mut dyn Formatter,
|
||||||
workspace_command: &WorkspaceCommandHelper,
|
workspace_command: &WorkspaceCommandHelper,
|
||||||
|
|
|
@ -245,6 +245,7 @@ impl Ui {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Waits for the pager exits.
|
/// Waits for the pager exits.
|
||||||
|
#[instrument(skip_all)]
|
||||||
pub fn finalize_pager(&mut self) {
|
pub fn finalize_pager(&mut self) {
|
||||||
if let UiOutput::Paged {
|
if let UiOutput::Paged {
|
||||||
mut child,
|
mut child,
|
||||||
|
@ -351,6 +352,7 @@ pub struct OutputGuard {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for OutputGuard {
|
impl Drop for OutputGuard {
|
||||||
|
#[instrument(skip_all)]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
_ = self.output.write_all(self.text.as_bytes());
|
_ = self.output.write_all(self.text.as_bytes());
|
||||||
_ = self.output.flush();
|
_ = self.output.flush();
|
||||||
|
|
Loading…
Reference in a new issue