mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Add a TRANSACTION class to experiment with performance metrics in nightlies
This commit is contained in:
parent
f6c305cea6
commit
dea46f7780
@ -72,9 +72,9 @@ static std::string GetSentryBreadCrumbLevel( BREADCRUMB_LEVEL aLevel )
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace APP_MONITOR
|
||||||
void APP_MONITOR::AddBreadcrumb( BREADCRUMB_TYPE aType, const wxString& aMsg, const wxString& aCategory,
|
{
|
||||||
BREADCRUMB_LEVEL aLevel )
|
void AddBreadcrumb( BREADCRUMB_TYPE aType, const wxString& aMsg, const wxString& aCategory, BREADCRUMB_LEVEL aLevel )
|
||||||
{
|
{
|
||||||
#ifdef KICAD_USE_SENTRY
|
#ifdef KICAD_USE_SENTRY
|
||||||
if( !Pgm().IsSentryOptedIn() )
|
if( !Pgm().IsSentryOptedIn() )
|
||||||
@ -98,7 +98,7 @@ void APP_MONITOR::AddBreadcrumb( BREADCRUMB_TYPE aType, const wxString& aMsg, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void APP_MONITOR::AddNavigationBreadcrumb( const wxString& aMsg, const wxString& aCategory )
|
void AddNavigationBreadcrumb( const wxString& aMsg, const wxString& aCategory )
|
||||||
{
|
{
|
||||||
#ifdef KICAD_USE_SENTRY
|
#ifdef KICAD_USE_SENTRY
|
||||||
AddBreadcrumb( BREADCRUMB_TYPE::NAVIGATION, aMsg, aCategory, BREADCRUMB_LEVEL::INFO );
|
AddBreadcrumb( BREADCRUMB_TYPE::NAVIGATION, aMsg, aCategory, BREADCRUMB_LEVEL::INFO );
|
||||||
@ -106,9 +106,102 @@ void APP_MONITOR::AddNavigationBreadcrumb( const wxString& aMsg, const wxString&
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void APP_MONITOR::AddTransactionBreadcrumb( const wxString& aMsg, const wxString& aCategory )
|
void AddTransactionBreadcrumb( const wxString& aMsg, const wxString& aCategory )
|
||||||
{
|
{
|
||||||
#ifdef KICAD_USE_SENTRY
|
#ifdef KICAD_USE_SENTRY
|
||||||
AddBreadcrumb( BREADCRUMB_TYPE::TRANSACTION, aMsg, aCategory, BREADCRUMB_LEVEL::INFO );
|
AddBreadcrumb( BREADCRUMB_TYPE::TRANSACTION, aMsg, aCategory, BREADCRUMB_LEVEL::INFO );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TRANSACTION_IMPL
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TRANSACTION_IMPL( const std::string& aName, const std::string& aOperation )
|
||||||
|
{
|
||||||
|
m_ctx = sentry_transaction_context_new( aName.c_str(), aOperation.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
~TRANSACTION_IMPL() {
|
||||||
|
Finish();
|
||||||
|
|
||||||
|
// note m_ctx is handled by sentry
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
m_tx = sentry_transaction_start( m_ctx, sentry_value_new_null() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Finish()
|
||||||
|
{
|
||||||
|
FinishSpan();
|
||||||
|
|
||||||
|
if( m_tx )
|
||||||
|
{
|
||||||
|
sentry_transaction_finish( m_tx );
|
||||||
|
m_tx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartSpan( const std::string& aOperation, const std::string& aDescription )
|
||||||
|
{
|
||||||
|
if( m_span )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( !m_tx )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_span = sentry_transaction_start_child( m_tx, aOperation.c_str(), aDescription.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void FinishSpan()
|
||||||
|
{
|
||||||
|
if( m_span )
|
||||||
|
{
|
||||||
|
sentry_span_finish( m_span );
|
||||||
|
m_span = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
sentry_transaction_context_t* m_ctx;
|
||||||
|
sentry_transaction_t* m_tx = nullptr;
|
||||||
|
sentry_span_t* m_span = nullptr;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TRANSACTION::TRANSACTION( const std::string& aName, const std::string& aOperation )
|
||||||
|
{
|
||||||
|
m_impl = new TRANSACTION_IMPL( aName, aOperation );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TRANSACTION::~TRANSACTION()
|
||||||
|
{
|
||||||
|
delete m_impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TRANSACTION::Start()
|
||||||
|
{
|
||||||
|
m_impl->Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TRANSACTION::StartSpan( const std::string& aOperation, const std::string& aDescription )
|
||||||
|
{
|
||||||
|
m_impl->StartSpan( aOperation, aDescription );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TRANSACTION::Finish()
|
||||||
|
{
|
||||||
|
m_impl->Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TRANSACTION::FinishSpan()
|
||||||
|
{
|
||||||
|
m_impl->FinishSpan();
|
||||||
|
}
|
@ -337,7 +337,8 @@ void PGM_BASE::sentryInit()
|
|||||||
#ifndef KICAD_SENTRY_DSN
|
#ifndef KICAD_SENTRY_DSN
|
||||||
# error "Project configuration error, missing KICAD_SENTRY_DSN"
|
# error "Project configuration error, missing KICAD_SENTRY_DSN"
|
||||||
#endif
|
#endif
|
||||||
|
// only capture 5% of transactions
|
||||||
|
sentry_options_set_traces_sample_rate( options, 0.05 );
|
||||||
sentry_options_set_dsn( options, KICAD_SENTRY_DSN );
|
sentry_options_set_dsn( options, KICAD_SENTRY_DSN );
|
||||||
|
|
||||||
wxFileName tmp;
|
wxFileName tmp;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <future>
|
#include <future>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <app_monitor.h>
|
||||||
#include <core/profile.h>
|
#include <core/profile.h>
|
||||||
#include <core/kicad_algo.h>
|
#include <core/kicad_algo.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
@ -739,11 +740,14 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
|
|||||||
std::function<void( SCH_ITEM* )>* aChangedItemHandler,
|
std::function<void( SCH_ITEM* )>* aChangedItemHandler,
|
||||||
PROGRESS_REPORTER* aProgressReporter )
|
PROGRESS_REPORTER* aProgressReporter )
|
||||||
{
|
{
|
||||||
|
APP_MONITOR::TRANSACTION monitorTrans( "CONNECTION_GRAPH::Recalculate", "Recalculate" );
|
||||||
PROF_TIMER recalc_time( "CONNECTION_GRAPH::Recalculate" );
|
PROF_TIMER recalc_time( "CONNECTION_GRAPH::Recalculate" );
|
||||||
|
monitorTrans.Start();
|
||||||
|
|
||||||
if( aUnconditional )
|
if( aUnconditional )
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
|
monitorTrans.StartSpan( "updateItemConnectivity", "" );
|
||||||
PROF_TIMER update_items( "updateItemConnectivity" );
|
PROF_TIMER update_items( "updateItemConnectivity" );
|
||||||
|
|
||||||
m_sheetList = aSheetList;
|
m_sheetList = aSheetList;
|
||||||
@ -858,20 +862,27 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
|
|||||||
for( SCH_ITEM* item : dirty_items )
|
for( SCH_ITEM* item : dirty_items )
|
||||||
item->SetConnectivityDirty( false );
|
item->SetConnectivityDirty( false );
|
||||||
|
|
||||||
|
|
||||||
|
monitorTrans.FinishSpan();
|
||||||
if( wxLog::IsAllowedTraceMask( DanglingProfileMask ) )
|
if( wxLog::IsAllowedTraceMask( DanglingProfileMask ) )
|
||||||
update_items.Show();
|
update_items.Show();
|
||||||
|
|
||||||
PROF_TIMER build_graph( "buildConnectionGraph" );
|
PROF_TIMER build_graph( "buildConnectionGraph" );
|
||||||
|
monitorTrans.StartSpan( "BuildConnectionGraph", "" );
|
||||||
|
|
||||||
buildConnectionGraph( aChangedItemHandler, aUnconditional );
|
buildConnectionGraph( aChangedItemHandler, aUnconditional );
|
||||||
|
|
||||||
if( wxLog::IsAllowedTraceMask( DanglingProfileMask ) )
|
if( wxLog::IsAllowedTraceMask( DanglingProfileMask ) )
|
||||||
build_graph.Show();
|
build_graph.Show();
|
||||||
|
|
||||||
|
monitorTrans.FinishSpan();
|
||||||
|
|
||||||
recalc_time.Stop();
|
recalc_time.Stop();
|
||||||
|
|
||||||
if( wxLog::IsAllowedTraceMask( DanglingProfileMask ) )
|
if( wxLog::IsAllowedTraceMask( DanglingProfileMask ) )
|
||||||
recalc_time.Show();
|
recalc_time.Show();
|
||||||
|
|
||||||
|
monitorTrans.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +51,24 @@ namespace APP_MONITOR
|
|||||||
DBG
|
DBG
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TRANSACTION_IMPL;
|
||||||
|
|
||||||
|
class KICOMMON_API TRANSACTION
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TRANSACTION( const std::string& aName, const std::string& aOperation );
|
||||||
|
~TRANSACTION();
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
void StartSpan( const std::string& aOperation, const std::string& aDescription );
|
||||||
|
void FinishSpan();
|
||||||
|
void Finish();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// We use a IMPL to avoid seeding sentry everywhere
|
||||||
|
TRANSACTION_IMPL* m_impl;
|
||||||
|
};
|
||||||
|
|
||||||
KICOMMON_API void AddBreadcrumb( BREADCRUMB_TYPE aType, const wxString& aMsg, const wxString& aCategory,
|
KICOMMON_API void AddBreadcrumb( BREADCRUMB_TYPE aType, const wxString& aMsg, const wxString& aCategory,
|
||||||
BREADCRUMB_LEVEL aLevel = BREADCRUMB_LEVEL::INFO );
|
BREADCRUMB_LEVEL aLevel = BREADCRUMB_LEVEL::INFO );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user