13
0

add some initial timing points for dsp stats

This commit is contained in:
Paul Davis 2021-06-11 15:38:58 -06:00
parent 462352102c
commit 1777cf8f69
6 changed files with 44 additions and 0 deletions

View File

@ -849,6 +849,17 @@ public:
return false; return false;
} }
enum TimingTypes {
DeviceWait = 0,
PreProcess = 1,
ProcessCallback = 2,
PostProcess = 3,
/* end */
NTT = 4
};
PBD::TimingStats dsp_stats[NTT];
protected: protected:
AudioBackendInfo& _info; AudioBackendInfo& _info;
AudioEngine& engine; AudioEngine& engine;

View File

@ -250,6 +250,14 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr
void add_pending_port_deletion (Port*); void add_pending_port_deletion (Port*);
void queue_latency_update (bool); void queue_latency_update (bool);
enum TimingTypes {
ProcessCallback = 0,
/* end */
NTT = 1
};
PBD::TimingStats dsp_stats[NTT];
private: private:
AudioEngine (); AudioEngine ();

View File

@ -1322,6 +1322,17 @@ public:
std::vector<struct ptflookup> ptfwavpair; std::vector<struct ptflookup> ptfwavpair;
SourceList pt_imported_sources; SourceList pt_imported_sources;
enum TimingTypes {
OverallProcess = 0,
ProcessFunction = 1,
NoRoll = 2,
Roll = 3,
/* end */
NTT = 4
};
PBD::TimingStats dsp_stats[NTT];
protected: protected:
friend class AudioEngine; friend class AudioEngine;
void set_block_size (pframes_t nframes); void set_block_size (pframes_t nframes);

View File

@ -228,6 +228,7 @@ __attribute__((annotate("realtime")))
int int
AudioEngine::process_callback (pframes_t nframes) AudioEngine::process_callback (pframes_t nframes)
{ {
TimerRAII tr (dsp_stats[ProcessCallback]);
Glib::Threads::Mutex::Lock tm (_process_lock, Glib::Threads::TRY_LOCK); Glib::Threads::Mutex::Lock tm (_process_lock, Glib::Threads::TRY_LOCK);
Port::set_speed_ratio (1.0); Port::set_speed_ratio (1.0);

View File

@ -74,6 +74,8 @@ using namespace std;
void void
Session::process (pframes_t nframes) Session::process (pframes_t nframes)
{ {
TimerRAII tr (dsp_stats[OverallProcess]);
samplepos_t transport_at_start = _transport_sample; samplepos_t transport_at_start = _transport_sample;
_silent = false; _silent = false;
@ -166,6 +168,7 @@ int
Session::no_roll (pframes_t nframes) Session::no_roll (pframes_t nframes)
{ {
PT_TIMING_CHECK (4); PT_TIMING_CHECK (4);
TimerRAII tr (dsp_stats[NoRoll]);
samplepos_t end_sample = _transport_sample + floor (nframes * _transport_fsm->transport_speed()); samplepos_t end_sample = _transport_sample + floor (nframes * _transport_fsm->transport_speed());
int ret = 0; int ret = 0;
@ -212,6 +215,7 @@ Session::no_roll (pframes_t nframes)
int int
Session::process_routes (pframes_t nframes, bool& need_butler) Session::process_routes (pframes_t nframes, bool& need_butler)
{ {
TimerRAII tr (dsp_stats[Roll]);
boost::shared_ptr<RouteList> r = routes.reader (); boost::shared_ptr<RouteList> r = routes.reader ();
const samplepos_t start_sample = _transport_sample; const samplepos_t start_sample = _transport_sample;
@ -331,6 +335,7 @@ void
Session::process_with_events (pframes_t nframes) Session::process_with_events (pframes_t nframes)
{ {
PT_TIMING_CHECK (3); PT_TIMING_CHECK (3);
TimerRAII tr (dsp_stats[ProcessFunction]);
SessionEvent* ev; SessionEvent* ev;
pframes_t this_nframes; pframes_t this_nframes;
@ -631,6 +636,7 @@ Session::transport_locked () const
void void
Session::process_without_events (pframes_t nframes) Session::process_without_events (pframes_t nframes)
{ {
TimerRAII tr (dsp_stats[ProcessFunction]);
bool session_needs_butler = false; bool session_needs_butler = false;
samplecnt_t samples_moved; samplecnt_t samples_moved;

View File

@ -1852,9 +1852,12 @@ AlsaAudioBackend::main_process_thread ()
} }
if (!_freewheel) { if (!_freewheel) {
dsp_stats[DeviceWait].start();
nr = _pcmi->pcm_wait (); nr = _pcmi->pcm_wait ();
dsp_stats[DeviceWait].update();
/* update DLL */ /* update DLL */
dsp_stats[PreProcess].start();
uint64_t clock0 = g_get_monotonic_time (); uint64_t clock0 = g_get_monotonic_time ();
if (reset_dll || last_n_periods != 1) { if (reset_dll || last_n_periods != 1) {
reset_dll = false; reset_dll = false;
@ -1957,11 +1960,13 @@ AlsaAudioBackend::main_process_thread ()
/* call engine process callback */ /* call engine process callback */
_last_process_start = g_get_monotonic_time (); _last_process_start = g_get_monotonic_time ();
dsp_stats[PreProcess].update();
if (engine.process_callback (_samples_per_period)) { if (engine.process_callback (_samples_per_period)) {
_pcmi->pcm_stop (); _pcmi->pcm_stop ();
_active = false; _active = false;
return 0; return 0;
} }
dsp_stats[PostProcess].start ();
/* only used when adding/removing MIDI device/system ports */ /* only used when adding/removing MIDI device/system ports */
pthread_mutex_lock (&_device_port_mutex); pthread_mutex_lock (&_device_port_mutex);
@ -2012,6 +2017,8 @@ AlsaAudioBackend::main_process_thread ()
_dsp_load_calc.set_stop_timestamp_us (g_get_monotonic_time ()); _dsp_load_calc.set_stop_timestamp_us (g_get_monotonic_time ());
_dsp_load = _dsp_load_calc.get_dsp_load (); _dsp_load = _dsp_load_calc.get_dsp_load ();
++last_n_periods; ++last_n_periods;
dsp_stats[PostProcess].update ();
} }
if (xrun && (_pcmi->capt_xrun () > 0 || _pcmi->play_xrun () > 0)) { if (xrun && (_pcmi->capt_xrun () > 0 || _pcmi->play_xrun () > 0)) {