mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Improve the debugging experience in the puffin reports
This commit is contained in:
parent
c45c6cf54c
commit
f2a9e1ebbb
@ -17,6 +17,8 @@ tasks individally, but should be much faster since we are only performing
|
||||
one indexing operation.
|
||||
*/
|
||||
|
||||
use core::fmt;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::{self, File};
|
||||
@ -199,6 +201,29 @@ impl Batch {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Batch {
|
||||
/// A text used when we debug the profiling reports.
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let index_uid = self.index_uid();
|
||||
let tasks = self.ids();
|
||||
let task = match self {
|
||||
Batch::TaskCancelation { .. } => Cow::Borrowed("TaskCancelation"),
|
||||
Batch::TaskDeletion(_) => Cow::Borrowed("TaskDeletion"),
|
||||
Batch::SnapshotCreation(_) => Cow::Borrowed("SnapshotCreation"),
|
||||
Batch::Dump(_) => Cow::Borrowed("Dump"),
|
||||
Batch::IndexOperation { op, .. } => Cow::Owned(op.to_string()),
|
||||
Batch::IndexCreation { .. } => Cow::Borrowed("IndexCreation"),
|
||||
Batch::IndexUpdate { .. } => Cow::Borrowed("IndexUpdate"),
|
||||
Batch::IndexDeletion { .. } => Cow::Borrowed("IndexDeletion"),
|
||||
Batch::IndexSwap { .. } => Cow::Borrowed("IndexSwap"),
|
||||
};
|
||||
match index_uid {
|
||||
Some(name) => f.write_fmt(format_args!("{task} on {name:?} from tasks: {tasks:?}")),
|
||||
None => f.write_fmt(format_args!("{task} from tasks: {tasks:?}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexOperation {
|
||||
pub fn index_uid(&self) -> &str {
|
||||
match self {
|
||||
@ -213,6 +238,30 @@ impl IndexOperation {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for IndexOperation {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
IndexOperation::DocumentOperation { .. } => {
|
||||
f.write_str("IndexOperation::DocumentOperation")
|
||||
}
|
||||
IndexOperation::DocumentDeletion { .. } => {
|
||||
f.write_str("IndexOperation::DocumentDeletion")
|
||||
}
|
||||
IndexOperation::IndexDocumentDeletionByFilter { .. } => {
|
||||
f.write_str("IndexOperation::IndexDocumentDeletionByFilter")
|
||||
}
|
||||
IndexOperation::DocumentClear { .. } => f.write_str("IndexOperation::DocumentClear"),
|
||||
IndexOperation::Settings { .. } => f.write_str("IndexOperation::Settings"),
|
||||
IndexOperation::DocumentClearAndSetting { .. } => {
|
||||
f.write_str("IndexOperation::DocumentClearAndSetting")
|
||||
}
|
||||
IndexOperation::SettingsAndDocumentOperation { .. } => {
|
||||
f.write_str("IndexOperation::SettingsAndDocumentOperation")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexScheduler {
|
||||
/// Convert an [`BatchKind`](crate::autobatcher::BatchKind) into a [`Batch`].
|
||||
///
|
||||
@ -581,7 +630,7 @@ impl IndexScheduler {
|
||||
self.breakpoint(crate::Breakpoint::InsideProcessBatch);
|
||||
}
|
||||
|
||||
puffin::profile_function!(format!("{:?}", batch));
|
||||
puffin::profile_function!(batch.to_string());
|
||||
|
||||
match batch {
|
||||
Batch::TaskCancelation { mut task, previous_started_at, previous_processing_tasks } => {
|
||||
|
Loading…
Reference in New Issue
Block a user