mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 12:54:26 +01:00
Use the runtime feature to enable puffin report exporting
This commit is contained in:
parent
0d4acf2daa
commit
90a626bf80
@ -53,6 +53,7 @@ use meilisearch_types::milli::documents::DocumentsBatchBuilder;
|
|||||||
use meilisearch_types::milli::update::IndexerConfig;
|
use meilisearch_types::milli::update::IndexerConfig;
|
||||||
use meilisearch_types::milli::{self, CboRoaringBitmapCodec, Index, RoaringBitmapCodec, BEU32};
|
use meilisearch_types::milli::{self, CboRoaringBitmapCodec, Index, RoaringBitmapCodec, BEU32};
|
||||||
use meilisearch_types::tasks::{Kind, KindWithContent, Status, Task};
|
use meilisearch_types::tasks::{Kind, KindWithContent, Status, Task};
|
||||||
|
use puffin::FrameView;
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
use synchronoise::SignalEvent;
|
use synchronoise::SignalEvent;
|
||||||
use time::format_description::well_known::Rfc3339;
|
use time::format_description::well_known::Rfc3339;
|
||||||
@ -1072,6 +1073,8 @@ impl IndexScheduler {
|
|||||||
self.breakpoint(Breakpoint::Start);
|
self.breakpoint(Breakpoint::Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let puffin_enabled = self.features()?.check_puffin().is_ok();
|
||||||
|
puffin::set_scopes_on(puffin_enabled);
|
||||||
puffin::GlobalProfiler::lock().new_frame();
|
puffin::GlobalProfiler::lock().new_frame();
|
||||||
|
|
||||||
self.cleanup_task_queue()?;
|
self.cleanup_task_queue()?;
|
||||||
@ -1081,15 +1084,19 @@ impl IndexScheduler {
|
|||||||
match self.create_next_batch(&rtxn).map_err(|e| Error::CreateBatch(Box::new(e)))? {
|
match self.create_next_batch(&rtxn).map_err(|e| Error::CreateBatch(Box::new(e)))? {
|
||||||
Some(batch) => batch,
|
Some(batch) => batch,
|
||||||
None => {
|
None => {
|
||||||
// Let's write the previous save to disk but only if
|
// Let's write the previous frame to disk but only if
|
||||||
// the user wanted to profile with puffin.
|
// the user wanted to profile with puffin.
|
||||||
|
if puffin_enabled {
|
||||||
if let Some(global_frame_view) = &self.puffin_frame {
|
if let Some(global_frame_view) = &self.puffin_frame {
|
||||||
let frame_view = global_frame_view.lock();
|
let mut frame_view = global_frame_view.lock();
|
||||||
if !frame_view.is_empty() {
|
if !frame_view.is_empty() {
|
||||||
let mut file =
|
let now = OffsetDateTime::now_utc();
|
||||||
File::create(format!("{}.puffin", OffsetDateTime::now_utc()))?;
|
let mut file = File::create(format!("{}.puffin", now))?;
|
||||||
frame_view.save_to_writer(&mut file)?;
|
frame_view.save_to_writer(&mut file)?;
|
||||||
file.sync_all()?;
|
file.sync_all()?;
|
||||||
|
// We erase everything on this frame as it is not more useful.
|
||||||
|
*frame_view = FrameView::default();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user