Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::QueryProfiler Class Reference

QueryProfiler collects the profiling metrics of a query. More...

Collaboration diagram for duckdb::QueryProfiler:

Public Types

using TreeMap = reference_map_t< const PhysicalOperator, reference< ProfilingNode > >
 

Public Member Functions

DUCKDB_API QueryProfiler (ClientContext &context)
 
DUCKDB_API bool IsEnabled () const
 
DUCKDB_API bool IsDetailedEnabled () const
 
DUCKDB_API ProfilerPrintFormat GetPrintFormat (ExplainFormat format=ExplainFormat::DEFAULT) const
 
DUCKDB_API bool PrintOptimizerOutput () const
 
DUCKDB_API string GetSaveLocation () const
 
DUCKDB_API void Start (const string &query)
 
DUCKDB_API void Reset ()
 
DUCKDB_API void StartQuery (const string &query, bool is_explain_analyze=false, bool start_at_optimizer=false)
 
DUCKDB_API void EndQuery ()
 
DUCKDB_API void FinalizeMetrics ()
 Finalize query metrics for output; safe to call multiple times.
 
DUCKDB_API void AddToCounter (MetricType type, const idx_t amount)
 Adds amount to a specific metric type.
 
DUCKDB_API ActiveTimer StartTimer (MetricType type)
 Start/End a timer for a specific metric type.
 
DUCKDB_API void StartExplainAnalyze ()
 
DUCKDB_API void Flush (OperatorProfiler &profiler)
 Adds the timings gathered by an OperatorProfiler to this query profiler.
 
DUCKDB_API void SetBlockedTime (const double &blocked_thread_time)
 Adds the top level query information to the global profiler.
 
DUCKDB_API void StartPhase (MetricType phase_metric)
 
DUCKDB_API void EndPhase ()
 
DUCKDB_API void Initialize (const PhysicalOperator &root)
 
DUCKDB_API string QueryTreeToString () const
 
DUCKDB_API void QueryTreeToStream (std::ostream &str) const
 
DUCKDB_API void Print ()
 
DUCKDB_API string ToString (ExplainFormat format=ExplainFormat::DEFAULT) const
 
DUCKDB_API string ToString (ProfilerPrintFormat format) const
 
DUCKDB_API void ToLog () const
 
DUCKDB_API string ToJSON () const
 
DUCKDB_API void WriteToFile (const char *path, string &info) const
 
DUCKDB_API idx_t GetBytesRead () const
 
DUCKDB_API idx_t GetBytesWritten () const
 
idx_t OperatorSize ()
 
void Finalize (ProfilingNode &node)
 
optional_ptr< ProfilingNodeGetRoot ()
 Return the root of the query tree.
 
DUCKDB_API void GetRootUnderLock (const std::function< void(optional_ptr< ProfilingNode >)> &callback)
 
const TreeMapGetTreeMap () const
 

Static Public Member Functions

static DUCKDB_API QueryProfilerGet (ClientContext &context)
 
static Value JSONSanitize (const Value &input)
 
static string JSONSanitize (const string &text)
 
static string DrawPadded (const string &str, idx_t width)
 

Private Types

using PhaseTimingStorage = unordered_map< MetricType, double, MetricTypeHashFunction >
 A mapping of the phase names to the timings.
 
using PhaseTimingItem = PhaseTimingStorage::value_type
 

Private Member Functions

unique_ptr< ProfilingNodeCreateTree (const PhysicalOperator &root, const profiler_settings_t &settings, const idx_t depth=0)
 
void Render (const ProfilingNode &node, std::ostream &str) const
 
string RenderDisabledMessage (ProfilerPrintFormat format) const
 
void MoveOptimizerPhasesToRoot ()
 
void FinalizeMetricsInternal ()
 
bool OperatorRequiresProfiling (const PhysicalOperatorType op_type)
 
ExplainFormat GetExplainFormat (ProfilerPrintFormat format) const
 

Private Attributes

ClientContextcontext
 
bool running
 Whether or not the query profiler is running.
 
std::mutex lock
 The lock used for accessing the global query profiler or flushing information to it from a thread.
 
bool query_requires_profiling
 Whether or not the query requires profiling.
 
unique_ptr< ProfilingNoderoot
 The root of the query tree.
 
QueryMetrics query_metrics
 Top level query information.
 
TreeMap tree_map
 A map of a Physical Operator pointer to a tree node.
 
bool is_explain_analyze
 Whether or not we are running as part of a explain_analyze query.
 
bool metrics_finalized
 Whether root metrics have been finalized for output.
 
Profiler phase_profiler
 The timer used to time the individual phases of the planning process.
 
PhaseTimingStorage phase_timings
 
vector< MetricType > phase_stack
 The stack of currently active phases.
 

Detailed Description

QueryProfiler collects the profiling metrics of a query.

Member Function Documentation

◆ ToString()

DUCKDB_API string duckdb::QueryProfiler::ToString ( ExplainFormat  format = ExplainFormat::DEFAULT) const

return the printed as a string. Unlike ToString, which is always formatted as a string, the return value is formatted based on the current print format (see GetPrintFormat()).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OperatorSize()

idx_t duckdb::QueryProfiler::OperatorSize ( )
inline
36878 {
36879 return tree_map.size();
36880 }
TreeMap tree_map
A map of a Physical Operator pointer to a tree node.
Definition duckdb.hpp:36920

◆ GetRoot()

optional_ptr< ProfilingNode > duckdb::QueryProfiler::GetRoot ( )
inline

Return the root of the query tree.

36885 {
36886 return root.get();
36887 }
unique_ptr< ProfilingNode > root
The root of the query tree.
Definition duckdb.hpp:36914
Here is the caller graph for this function:

◆ GetRootUnderLock()

DUCKDB_API void duckdb::QueryProfiler::GetRootUnderLock ( const std::function< void(optional_ptr< ProfilingNode >)> &  callback)
inline

Provides access to the root of the query tree, but ensures there are no concurrent modifications. This can be useful when implementing continuous profiling or making customizations.

36891 {
36892 lock_guard<std::mutex> guard(lock);
36893 callback(GetRoot());
36894 }
optional_ptr< ProfilingNode > GetRoot()
Return the root of the query tree.
Definition duckdb.hpp:36885
std::mutex lock
The lock used for accessing the global query profiler or flushing information to it from a thread.
Definition duckdb.hpp:36908
Here is the call graph for this function:

◆ GetTreeMap()

const TreeMap & duckdb::QueryProfiler::GetTreeMap ( ) const
inline
36927 {
36928 return tree_map;
36929 }

◆ OperatorRequiresProfiling()

bool duckdb::QueryProfiler::OperatorRequiresProfiling ( const PhysicalOperatorType  op_type)
private

Check whether or not an operator type requires query profiling. If none of the ops in a query require profiling no profiling information is output.


The documentation for this class was generated from the following file: