Commit e3a897cf authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove write-only timer statistics

The implementation was slow/inefficient. This is really silly for
_performance_ counters. And contrary to the other statistics, nothing
actually reads them, except for debug logs.

If you really want debug-only performance timers, use this:

    mtime_t start, end;

    start = mdate();
    compute_decimals_of_Pi(100);
    end = mdate();
    msg_Dbg(obj, "spent %"PRIu64" us computing", end - start);
parent 4fc348b7
......@@ -115,7 +115,6 @@ enum
STATS_MAX,
STATS_MIN,
STATS_DERIVATIVE,
STATS_TIMER
};
struct counter_sample_t
......@@ -159,38 +158,8 @@ enum
STATS_SOUT_SEND_BITRATE,
STATS_DISPLAYED_PICTURES,
STATS_LOST_PICTURES,
STATS_TIMER_PLAYLIST_BUILD,
STATS_TIMER_ML_LOAD,
STATS_TIMER_ML_DUMP,
STATS_TIMER_INTERACTION,
STATS_TIMER_PREPARSE,
STATS_TIMER_INPUT_LAUNCHING,
STATS_TIMER_MODULE_NEED,
STATS_TIMER_VIDEO_FRAME_ENCODING,
STATS_TIMER_AUDIO_FRAME_ENCODING,
STATS_TIMER_SKINS_PLAYTREE_IMAGE,
};
/*********
* Timing
********/
VLC_API void stats_TimerStart(vlc_object_t*, const char *, unsigned int );
VLC_API void stats_TimerStop(vlc_object_t*, unsigned int);
VLC_API void stats_TimerDump(vlc_object_t*, unsigned int);
VLC_API void stats_TimersDumpAll(vlc_object_t*);
#define stats_TimerStart(a,b,c) stats_TimerStart( VLC_OBJECT(a), b,c )
#define stats_TimerStop(a,b) stats_TimerStop( VLC_OBJECT(a), b )
#define stats_TimerDump(a,b) stats_TimerDump( VLC_OBJECT(a), b )
#define stats_TimersDumpAll(a) stats_TimersDumpAll( VLC_OBJECT(a) )
VLC_API void stats_TimersCleanAll(vlc_object_t * );
#define stats_TimersCleanAll(a) stats_TimersCleanAll( VLC_OBJECT(a) )
VLC_API void stats_TimerClean(vlc_object_t *, unsigned int );
#define stats_TimerClean(a,b) stats_TimerClean( VLC_OBJECT(a), b )
/**
* @}
*/
......
......@@ -563,17 +563,12 @@ void CtrlTree::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h)
void CtrlTree::makeImage()
{
stats_TimerStart( getIntf(), "[Skins] Playlist image",
STATS_TIMER_SKINS_PLAYTREE_IMAGE );
delete m_pImage;
// Get the size of the control
const Position *pPos = getPosition();
if( !pPos )
{
stats_TimerStop( getIntf(), STATS_TIMER_SKINS_PLAYTREE_IMAGE );
return;
}
int width = pPos->getWidth();
int height = pPos->getHeight();
......@@ -645,7 +640,6 @@ void CtrlTree::makeImage()
m_rFont.drawString( *pStr, color, width-bitmapWidth*depth );
if( !pText )
{
stats_TimerStop( getIntf(), STATS_TIMER_SKINS_PLAYTREE_IMAGE );
return;
}
if( it->size() )
......@@ -695,7 +689,6 @@ void CtrlTree::makeImage()
delete pText;
}
}
stats_TimerStop( getIntf(), STATS_TIMER_SKINS_PLAYTREE_IMAGE );
}
CtrlTree::Iterator CtrlTree::findItemAtPos( int pos )
......
......@@ -45,23 +45,6 @@ static const int pi_channels_maps[6] =
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
};
static inline void audio_timer_start( encoder_t * p_encoder )
{
stats_TimerStart( p_encoder, "encoding audio frame",
STATS_TIMER_AUDIO_FRAME_ENCODING );
}
static inline void audio_timer_stop( encoder_t * p_encoder )
{
stats_TimerStop( p_encoder, STATS_TIMER_AUDIO_FRAME_ENCODING );
}
static inline void audio_timer_close( encoder_t * p_encoder )
{
stats_TimerDump( p_encoder, STATS_TIMER_AUDIO_FRAME_ENCODING );
stats_TimerClean( p_encoder, STATS_TIMER_AUDIO_FRAME_ENCODING );
}
static aout_buffer_t *audio_new_buffer( decoder_t *p_dec, int i_samples )
{
block_t *p_block;
......@@ -311,8 +294,6 @@ int transcode_audio_new( sout_stream_t *p_stream,
void transcode_audio_close( sout_stream_id_t *id )
{
audio_timer_close( id->p_encoder );
/* Close decoder */
if( id->p_decoder->p_module )
module_unneed( id->p_decoder, id->p_decoder->p_module );
......@@ -377,9 +358,7 @@ int transcode_audio_process( sout_stream_t *p_stream,
p_audio_buf->i_dts = p_audio_buf->i_pts;
audio_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_audio( id->p_encoder, p_audio_buf );
audio_timer_stop( id->p_encoder );
block_ChainAppend( out, p_block );
block_Release( p_audio_buf );
......
......@@ -42,23 +42,6 @@ struct decoder_owner_sys_t
sout_stream_sys_t *p_sys;
};
static inline void video_timer_start( encoder_t * p_encoder )
{
stats_TimerStart( p_encoder, "encoding video frame",
STATS_TIMER_VIDEO_FRAME_ENCODING );
}
static inline void video_timer_stop( encoder_t * p_encoder )
{
stats_TimerStop( p_encoder, STATS_TIMER_VIDEO_FRAME_ENCODING );
}
static inline void video_timer_close( encoder_t * p_encoder )
{
stats_TimerDump( p_encoder, STATS_TIMER_VIDEO_FRAME_ENCODING );
stats_TimerClean( p_encoder, STATS_TIMER_VIDEO_FRAME_ENCODING );
}
static void video_del_buffer_decoder( decoder_t *p_decoder, picture_t *p_pic )
{
VLC_UNUSED(p_decoder);
......@@ -150,9 +133,7 @@ static void* EncoderThread( void *obj )
p_sys->i_first_pic %= PICTURE_RING_SIZE;
vlc_mutex_unlock( &p_sys->lock_out );
video_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic );
video_timer_stop( id->p_encoder );
vlc_mutex_lock( &p_sys->lock_out );
block_ChainAppend( &p_sys->p_buffers, p_block );
......@@ -571,8 +552,6 @@ void transcode_video_close( sout_stream_t *p_stream,
vlc_cond_destroy( &p_stream->p_sys->cond );
}
video_timer_close( id->p_encoder );
/* Close decoder */
if( id->p_decoder->p_module )
module_unneed( id->p_decoder, id->p_decoder->p_module );
......@@ -606,9 +585,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
{
block_t *p_block;
do {
video_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_video(id->p_encoder, NULL );
video_timer_stop( id->p_encoder );
block_ChainAppend( out, p_block );
} while( p_block );
}
......@@ -742,10 +719,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
{
block_t *p_block;
video_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic );
video_timer_stop( id->p_encoder );
block_ChainAppend( out, p_block );
}
......@@ -778,9 +752,7 @@ int transcode_video_process( sout_stream_t *p_stream, sout_stream_id_t *id,
{
block_t *p_block;
p_pic->date = i_pts;
video_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_video(id->p_encoder, p_pic);
video_timer_stop( id->p_encoder );
block_ChainAppend( out, p_block );
}
}
......
......@@ -333,11 +333,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
free( psz_name );
/* Start a timer to mesure how long it takes
* to launch an input */
stats_TimerStart( p_input, psz_timer_name,
STATS_TIMER_INPUT_LAUNCHING );
p_input->p = calloc( 1, sizeof( input_thread_private_t ) );
if( !p_input->p )
return NULL;
......@@ -511,9 +506,6 @@ static void Destructor( input_thread_t * p_input )
free( psz_name );
#endif
stats_TimerDump( p_input, STATS_TIMER_INPUT_LAUNCHING );
stats_TimerClean( p_input, STATS_TIMER_INPUT_LAUNCHING );
if( p_input->p->p_es_out_display )
es_out_Delete( p_input->p->p_es_out_display );
......@@ -736,9 +728,6 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
bool b_pause_after_eof = b_interactive &&
var_CreateGetBool( p_input, "play-and-pause" );
/* Start the timer */
stats_TimerStop( p_input, STATS_TIMER_INPUT_LAUNCHING );
while( vlc_object_alive( p_input ) && !p_input->b_error )
{
bool b_force_update;
......
......@@ -769,8 +769,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
/* Free playlist now, all threads are gone */
playlist_Destroy( p_playlist );
stats_TimersDumpAll( p_libvlc );
stats_TimersCleanAll( p_libvlc );
msg_Dbg( p_libvlc, "removing stats" );
......
......@@ -404,12 +404,6 @@ spu_RegisterChannel
spu_ClearChannel
sql_Create
sql_Destroy
stats_TimerClean
stats_TimerDump
stats_TimersCleanAll
stats_TimersDumpAll
stats_TimerStart
stats_TimerStop
stream_Block
stream_Control
stream_Delete
......
......@@ -40,7 +40,6 @@
static int CounterUpdate( vlc_object_t *p_this,
counter_t *p_counter,
vlc_value_t val, vlc_value_t * );
static void TimerDump( vlc_object_t *p_this, counter_t *p_counter, bool);
/*****************************************************************************
* Exported functions
......@@ -245,157 +244,6 @@ void stats_DumpInputStats( input_stats_t *p_stats )
vlc_mutex_unlock( &p_stats->lock );
}
#undef stats_TimerStart
void stats_TimerStart( vlc_object_t *p_obj, const char *psz_name,
unsigned int i_id )
{
libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
counter_t *p_counter = NULL;
if( !priv->b_stats ) return;
vlc_mutex_lock( &priv->timer_lock );
for( int i = 0 ; i < priv->i_timers; i++ )
{
if( priv->pp_timers[i]->i_id == i_id
&& priv->pp_timers[i]->p_obj == p_obj )
{
p_counter = priv->pp_timers[i];
break;
}
}
if( !p_counter )
{
counter_sample_t *p_sample;
p_counter = stats_CounterCreate( VLC_OBJECT(p_obj->p_libvlc),
VLC_VAR_TIME, STATS_TIMER );
if( !p_counter )
goto out;
p_counter->psz_name = strdup( psz_name );
p_counter->i_id = i_id;
p_counter->p_obj = p_obj;
INSERT_ELEM( priv->pp_timers, priv->i_timers,
priv->i_timers, p_counter );
/* 1st sample : if started: start_date, else last_time, b_started */
p_sample = (counter_sample_t *)malloc( sizeof( counter_sample_t ) );
INSERT_ELEM( p_counter->pp_samples, p_counter->i_samples,
p_counter->i_samples, p_sample );
p_sample->date = 0; p_sample->value.b_bool = 0;
/* 2nd sample : global_time, i_samples */
p_sample = (counter_sample_t *)malloc( sizeof( counter_sample_t ) );
INSERT_ELEM( p_counter->pp_samples, p_counter->i_samples,
p_counter->i_samples, p_sample );
p_sample->date = 0; p_sample->value.i_int = 0;
}
if( p_counter->pp_samples[0]->value.b_bool )
{
msg_Warn( p_obj, "timer '%s' was already started !", psz_name );
goto out;
}
p_counter->pp_samples[0]->value.b_bool = true;
p_counter->pp_samples[0]->date = mdate();
out:
vlc_mutex_unlock( &priv->timer_lock );
}
#undef stats_TimerStop
void stats_TimerStop( vlc_object_t *p_obj, unsigned int i_id )
{
counter_t *p_counter = NULL;
libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
if( !priv->b_stats ) return;
vlc_mutex_lock( &priv->timer_lock );
for( int i = 0 ; i < priv->i_timers; i++ )
{
if( priv->pp_timers[i]->i_id == i_id
&& priv->pp_timers[i]->p_obj == p_obj )
{
p_counter = priv->pp_timers[i];
break;
}
}
if( !p_counter || p_counter->i_samples != 2 )
{
msg_Err( p_obj, "timer does not exist" );
goto out;
}
p_counter->pp_samples[0]->value.b_bool = false;
p_counter->pp_samples[1]->value.i_int += 1;
p_counter->pp_samples[0]->date = mdate() - p_counter->pp_samples[0]->date;
p_counter->pp_samples[1]->date += p_counter->pp_samples[0]->date;
out:
vlc_mutex_unlock( &priv->timer_lock );
}
#undef stats_TimerDump
void stats_TimerDump( vlc_object_t *p_obj, unsigned int i_id )
{
counter_t *p_counter = NULL;
libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
if( !priv->b_stats ) return;
vlc_mutex_lock( &priv->timer_lock );
for( int i = 0 ; i < priv->i_timers; i++ )
{
if( priv->pp_timers[i]->i_id == i_id
&& priv->pp_timers[i]->p_obj == p_obj )
{
p_counter = priv->pp_timers[i];
break;
}
}
TimerDump( p_obj, p_counter, true );
vlc_mutex_unlock( &priv->timer_lock );
}
#undef stats_TimersDumpAll
void stats_TimersDumpAll( vlc_object_t *p_obj )
{
libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
if( !priv->b_stats ) return;
vlc_mutex_lock( &priv->timer_lock );
for ( int i = 0 ; i < priv->i_timers ; i++ )
TimerDump( p_obj, priv->pp_timers[i], false );
vlc_mutex_unlock( &priv->timer_lock );
}
#undef stats_TimerClean
void stats_TimerClean( vlc_object_t *p_obj, unsigned int i_id )
{
libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
vlc_mutex_lock( &priv->timer_lock );
for ( int i = priv->i_timers -1 ; i >= 0; i-- )
{
counter_t *p_counter = priv->pp_timers[i];
if( p_counter->i_id == i_id && p_counter->p_obj == p_obj )
{
REMOVE_ELEM( priv->pp_timers, priv->i_timers, i );
stats_CounterClean( p_counter );
}
}
vlc_mutex_unlock( &priv->timer_lock );
}
#undef stats_TimersCleanAll
void stats_TimersCleanAll( vlc_object_t *p_obj )
{
libvlc_priv_t *priv = libvlc_priv (p_obj->p_libvlc);
vlc_mutex_lock( &priv->timer_lock );
for ( int i = priv->i_timers -1 ; i >= 0; i-- )
{
counter_t *p_counter = priv->pp_timers[i];
REMOVE_ELEM( priv->pp_timers, priv->i_timers, i );
stats_CounterClean( p_counter );
}
vlc_mutex_unlock( &priv->timer_lock );
}
void stats_CounterClean( counter_t *p_c )
{
if( p_c )
......@@ -552,44 +400,3 @@ static int CounterUpdate( vlc_object_t *p_handler,
}
return VLC_SUCCESS;
}
static void TimerDump( vlc_object_t *p_obj, counter_t *p_counter,
bool b_total )
{
if( !p_counter )
return;
mtime_t last, total;
int64_t i_total;
if( p_counter->i_samples != 2 )
{
msg_Err( p_obj, "timer %s does not exist", p_counter->psz_name );
return;
}
i_total = p_counter->pp_samples[1]->value.i_int;
total = p_counter->pp_samples[1]->date;
if( p_counter->pp_samples[0]->value.b_bool )
{
last = mdate() - p_counter->pp_samples[0]->date;
i_total += 1;
total += last;
}
else
{
last = p_counter->pp_samples[0]->date;
}
if( b_total )
{
msg_Dbg( p_obj,
"TIMER %s : %.3f ms - Total %.3f ms / %"PRId64" intvls (Avg %.3f ms)",
p_counter->psz_name, (float)last/1000, (float)total/1000, i_total,
(float)(total)/(1000*(float)i_total ) );
}
else
{
msg_Dbg( p_obj,
"TIMER %s : Total %.3f ms / %"PRId64" intvls (Avg %.3f ms)",
p_counter->psz_name, (float)total/1000, i_total,
(float)(total)/(1000*(float)i_total ) );
}
}
......@@ -199,8 +199,6 @@ module_t *vlc_module_load(vlc_object_t *p_this, const char *psz_capability,
const char *psz_name, bool b_strict,
vlc_activate_t probe, ...)
{
stats_TimerStart( p_this, "module_need()", STATS_TIMER_MODULE_NEED );
module_list_t *p_list;
module_t *p_module;
int i_shortcuts = 0;
......@@ -222,9 +220,6 @@ module_t *vlc_module_load(vlc_object_t *p_this, const char *psz_capability,
if( !strcmp( psz_name, "none" ) )
{
free( psz_var );
stats_TimerStop( p_this, STATS_TIMER_MODULE_NEED );
stats_TimerDump( p_this, STATS_TIMER_MODULE_NEED );
stats_TimerClean( p_this, STATS_TIMER_MODULE_NEED );
return NULL;
}
......@@ -387,10 +382,6 @@ found_shortcut:
free( psz_shortcuts );
free( psz_var );
stats_TimerStop( p_this, STATS_TIMER_MODULE_NEED );
stats_TimerDump( p_this, STATS_TIMER_MODULE_NEED );
stats_TimerClean( p_this, STATS_TIMER_MODULE_NEED );
/* Don't forget that the module is still locked */
return p_module;
}
......
......@@ -167,9 +167,7 @@ int playlist_MLLoad( playlist_t *p_playlist )
pl_priv(p_playlist)->b_doing_ml = true;
PL_UNLOCK;
stats_TimerStart( p_playlist, "ML Load", STATS_TIMER_ML_LOAD );
input_Read( p_playlist, p_input );
stats_TimerStop( p_playlist,STATS_TIMER_ML_LOAD );
PL_LOCK;
pl_priv(p_playlist)->b_doing_ml = false;
......@@ -203,10 +201,8 @@ int playlist_MLDump( playlist_t *p_playlist )
strcat( psz_dirname, DIR_SEP "ml.xspf" );
stats_TimerStart( p_playlist, "ML Dump", STATS_TIMER_ML_DUMP );
playlist_Export( p_playlist, psz_dirname, p_playlist->p_media_library,
"export-xspf" );
stats_TimerStop( p_playlist, STATS_TIMER_ML_DUMP );
return VLC_SUCCESS;
}
......@@ -131,8 +131,6 @@ static void Preparse( playlist_t *p_playlist, input_item_t *p_item )
return;
}
stats_TimerStart( p_playlist, "Preparse run", STATS_TIMER_PREPARSE );
/* Do not preparse if it is already done (like by playing it) */
if( !input_item_IsPreparsed( p_item ) )
{
......@@ -141,8 +139,6 @@ static void Preparse( playlist_t *p_playlist, input_item_t *p_item )
var_SetAddress( p_playlist, "item-change", p_item );
}
stats_TimerStop( p_playlist, STATS_TIMER_PREPARSE );
}
/**
......
......@@ -168,8 +168,6 @@ static void ResetCurrentlyPlaying( playlist_t *p_playlist,
{
playlist_private_t *p_sys = pl_priv(p_playlist);
stats_TimerStart( p_playlist, "Items array build",
STATS_TIMER_PLAYLIST_BUILD );
PL_DEBUG( "rebuilding array of current - root %s",
PLI_NAME( p_sys->status.p_node ) );
ARRAY_RESET( p_playlist->current );
......@@ -204,7 +202,6 @@ static void ResetCurrentlyPlaying( playlist_t *p_playlist,
}
}
p_sys->b_reset_currently_playing = false;
stats_TimerStop( p_playlist, STATS_TIMER_PLAYLIST_BUILD );
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment