Changeset 26d5b73864aea7f4e6d01dba654235cb1accdf84

Show
Ignore:
Timestamp:
02/04/06 12:04:42 (3 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1139051082 +0000
git-parent:

[f8cac3e17afff983a591fbe2bf0cc101b53ae624]

git-author:
Clément Stenac <zorglub@videolan.org> 1139051082 +0000
Message:

* Avoid useless stats_Get calls
* Reduce vlc_object_find calls

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • NEWS

    rf99f42e r26d5b73  
    55 
    66Core support: 
     7 * Statistics collection (bitrates, packets, connections, ...) 
    78 
    89Input: 
     
    5051 
    5152Developers: 
     53 * New libvlc API (not finished yet) 
    5254 * Java bindings 
    53  
    54  
    55  
    5655 
    5756Changes between 0.8.4 and 0.8.4a: 
  • include/main.h

    rb76d7cf r26d5b73  
    6363    /* Do stats ? - We keep this boolean to avoid unneeded lookups */ 
    6464    vlc_bool_t             b_stats; 
     65    stats_handler_t       *p_stats; 
    6566 
    6667    /* Arch-specific variables */ 
  • include/vlc_messages.h

    r8d995e6 r26d5b73  
    250250VLC_EXPORT( void, stats_HandlerDestroy, (stats_handler_t*) ); 
    251251 
    252 #define stats_Update( a,b,c) __stats_Update( VLC_OBJECT( a ), b, c
    253 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, const char *, vlc_value_t) ); 
     252#define stats_Update( a,b,c, d) __stats_Update( VLC_OBJECT( a ), b, c, d
     253VLC_EXPORT( int, __stats_Update, (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *) ); 
    254254#define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d ) 
    255255VLC_EXPORT( int, __stats_Create, (vlc_object_t*, const char *, int, int) ); 
     
    278278    return i_ret; 
    279279} 
    280 #define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c
     280#define stats_UpdateInteger( a,b,c,d ) __stats_UpdateInteger( VLC_OBJECT(a),b,c,d
    281281static inline int __stats_UpdateInteger( vlc_object_t *p_obj, 
    282                                          const char *psz_name, int i ) 
    283 
     282                                         const char *psz_name, int i, int *pi_new ) 
     283
     284    int i_ret; 
    284285    vlc_value_t val; 
     286    vlc_value_t new_val; 
    285287    val.i_int = i; 
    286     return __stats_Update( p_obj, psz_name, val ); 
    287 
    288 #define stats_UpdateFloat( a,b,c ) __stats_UpdateFloat( VLC_OBJECT(a),b,c ) 
     288    i_ret = __stats_Update( p_obj, psz_name, val , &new_val ); 
     289    if( pi_new ) 
     290        *pi_new = new_val.i_int; 
     291    return i_ret; 
     292
     293#define stats_UpdateFloat( a,b,c,d ) __stats_UpdateFloat( VLC_OBJECT(a),b,c,d ) 
    289294static inline int __stats_UpdateFloat( vlc_object_t *p_obj, 
    290                                        const char *psz_name, float f
     295                                       const char *psz_name, float f, float *pf_new
    291296{ 
    292297    vlc_value_t val; 
     298    int i_ret; 
     299    vlc_value_t new_val; 
    293300    val.f_float = f; 
    294     return __stats_Update( p_obj, psz_name, val ); 
     301    i_ret =  __stats_Update( p_obj, psz_name, val, &new_val ); 
     302    if( pf_new ) 
     303        *pf_new = new_val.f_float; 
     304    return i_ret; 
    295305} 
    296306 
  • include/vlc_symbols.h

    r8d995e6 r26d5b73  
    125125int playlist_Delete (playlist_t *, int); 
    126126void aout_FiltersPlay (aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_buffer_t ** pp_input_buffer); 
    127 int __stats_Update (vlc_object_t*, const char *, vlc_value_t); 
     127int __stats_Update (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *); 
    128128int __stats_Get (vlc_object_t*, int, const char *, vlc_value_t*); 
    129129char* httpd_ClientIP (httpd_client_t *cl, char *psz_ip); 
     
    898898    void (*__intf_UserHide_inner) (vlc_object_t *, int); 
    899899    int (*__stats_Create_inner) (vlc_object_t*, const char *, int, int); 
    900     int (*__stats_Update_inner) (vlc_object_t*, const char *, vlc_value_t); 
     900    int (*__stats_Update_inner) (vlc_object_t*, const char *, vlc_value_t, vlc_value_t *); 
    901901    int (*__stats_Get_inner) (vlc_object_t*, int, const char *, vlc_value_t*); 
    902902    void (*stats_ComputeInputStats_inner) (input_thread_t*, input_stats_t*); 
  • modules/stream_out/transcode.c

    ra838001 r26d5b73  
    13291329                                                          &in )) ) 
    13301330    { 
    1331         stats_UpdateInteger( p_stream->p_parent->p_parent, "decoded_audio", 1 ); 
     1331        stats_UpdateInteger( p_stream->p_parent->p_parent, "decoded_audio", 1, NULL ); 
    13321332        if( p_sys->b_master_sync ) 
    13331333        { 
     
    17321732    { 
    17331733        subpicture_t *p_subpic = 0; 
    1734         stats_UpdateInteger( p_stream->p_parent->p_parent, "decoded_video", 1 ); 
     1734        stats_UpdateInteger( p_stream->p_parent->p_parent, "decoded_video", 1, NULL ); 
    17351735 
    17361736        if( p_stream->p_sout->i_out_pace_nocontrol && p_sys->b_hurry_up ) 
  • src/audio_output/dec.c

    r5bd61a8 r26d5b73  
    313313        if( p_input->p_input_thread ) 
    314314        { 
    315             stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 ); 
     315            stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1, 
     316                                 NULL ); 
    316317        } 
    317318        aout_BufferFree( p_buffer ); 
     
    368369    { 
    369370        stats_UpdateInteger( p_input->p_input_thread, 
    370                             "played_abuffers", 1 ); 
     371                            "played_abuffers", 1, NULL ); 
    371372    } 
    372373    vlc_mutex_unlock( &p_aout->mixer_lock ); 
  • src/audio_output/input.c

    r5bd61a8 r26d5b73  
    448448        if( p_input->p_input_thread ) 
    449449        { 
    450             stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 ); 
     450            stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1, 
     451                                 NULL ); 
    451452        } 
    452453    } 
     
    460461        if( p_input->p_input_thread ) 
    461462        { 
    462             stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 ); 
     463            stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1, 
     464                                 NULL ); 
    463465        } 
    464466        aout_BufferFree( p_buffer ); 
     
    501503        if( p_input->p_input_thread ) 
    502504        { 
    503             stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1 ); 
     505            stats_UpdateInteger( p_input->p_input_thread, "lost_abuffers", 1, 
     506                                 NULL ); 
    504507        } 
    505508        return 0; 
  • src/input/decoder.c

    r31e0a13 r26d5b73  
    628628                                                       &p_packetized_block )) ) 
    629629                    { 
    630                         stats_UpdateInteger( p_dec->p_parent, "decoded_audio", 1 ); 
     630                        stats_UpdateInteger( p_dec->p_parent, "decoded_audio", 1, NULL ); 
    631631                        /* FIXME the best would be to handle the case start_date < preroll < end_date 
    632632                         * but that's not easy with non raw audio stream */ 
     
    652652        else while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) ) 
    653653        { 
    654             stats_UpdateInteger( p_dec->p_parent, "decoded_audio", 1 ); 
     654            stats_UpdateInteger( p_dec->p_parent, "decoded_audio", 1, NULL ); 
    655655            if( p_dec->p_owner->i_preroll_end > 0 && 
    656656                p_aout_buf->start_date < p_dec->p_owner->i_preroll_end ) 
     
    699699                    { 
    700700                        stats_UpdateInteger( p_dec->p_parent, "decoded_video", 
    701                                                              1 ); 
     701                                                             1, NULL ); 
    702702                        if( p_dec->p_owner->i_preroll_end > 0 && 
    703703                            p_pic->date < p_dec->p_owner->i_preroll_end ) 
     
    720720        else while( (p_pic = p_dec->pf_decode_video( p_dec, &p_block )) ) 
    721721        { 
    722             stats_UpdateInteger( p_dec->p_parent, "decoded_video", 1 ); 
     722            stats_UpdateInteger( p_dec->p_parent, "decoded_video", 1 , NULL); 
    723723            if( p_dec->p_owner->i_preroll_end > 0 && 
    724724                p_pic->date < p_dec->p_owner->i_preroll_end ) 
     
    740740        while( (p_spu = p_dec->pf_decode_sub( p_dec, &p_block ) ) ) 
    741741        { 
    742             stats_UpdateInteger( p_dec->p_parent, "decoded_sub", 1 ); 
     742            stats_UpdateInteger( p_dec->p_parent, "decoded_sub", 1 , NULL); 
    743743            if( p_dec->p_owner->i_preroll_end > 0 && 
    744744                p_spu->i_start < p_dec->p_owner->i_preroll_end && 
  • src/input/es_out.c

    re6f3d0a r26d5b73  
    10341034    if( p_input->p_libvlc->b_stats ) 
    10351035    { 
    1036         stats_UpdateInteger( p_input, "demux_read", p_block->i_buffer ); 
    1037         stats_GetInteger( p_input, p_input->i_object_id, "demux_read", 
    1038                           &i_total ); 
    1039         stats_UpdateFloat( p_input , "demux_bitrate", (float)i_total ); 
     1036        stats_UpdateInteger( p_input, "demux_read", p_block->i_buffer, 
     1037                             &i_total ); 
     1038        stats_UpdateFloat( p_input , "demux_bitrate", (float)i_total, NULL ); 
    10401039    } 
    10411040 
  • src/input/stream.c

    re6f3d0a r26d5b73  
    15811581    { 
    15821582        i_read = p_access->pf_read( p_access, p_read, i_read ); 
    1583         stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read ); 
    1584         stats_GetInteger( s, s->p_parent->p_parent->i_object_id, 
    1585                           "read_bytes", &i_total ); 
     1583        stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read, 
     1584                             &i_total ); 
    15861585        stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate", 
    1587                           (float)i_total ); 
    1588         stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 ); 
     1586                          (float)i_total, NULL ); 
     1587        stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL ); 
    15891588        return i_read; 
    15901589    } 
     
    16151614 
    16161615    /* Update read bytes in input */ 
    1617     stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read ); 
    1618     stats_GetInteger( s, s->p_parent->p_parent->i_object_id, 
    1619                       "read_bytes", &i_total ); 
     1616    stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read, 
     1617                         &i_total ); 
    16201618    stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate", 
    1621                       (float)i_total ); 
    1622     stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 ); 
     1619                      (float)i_total, NULL ); 
     1620    stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL ); 
    16231621    return i_read; 
    16241622} 
     
    16391637        { 
    16401638            stats_UpdateInteger( s->p_parent->p_parent, "read_bytes", 
    1641                                  p_block->i_buffer ); 
    1642             stats_GetInteger( s, s->p_parent->p_parent->i_object_id, 
    1643                               "read_bytes", &i_total ); 
     1639                                 p_block->i_buffer, &i_total ); 
    16441640            stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate", 
    1645                               (float)i_total ); 
    1646             stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 ); 
     1641                              (float)i_total, NULL ); 
     1642            stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1, NULL ); 
    16471643        } 
    16481644        return p_block; 
     
    16761672    { 
    16771673        stats_UpdateInteger( s->p_parent->p_parent, "read_bytes", 
    1678                              p_block->i_buffer ); 
    1679         stats_GetInteger( s, s->p_parent->p_parent->i_object_id, 
    1680                           "read_bytes", &i_total ); 
     1674                             p_block->i_buffer, &i_total ); 
    16811675        stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate", 
    1682                           (float)i_total ); 
    1683         stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 ); 
     1676                          (float)i_total, NULL ); 
     1677        stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 , NULL); 
    16841678    } 
    16851679 
  • src/libvlc.c

    r9f30598 r26d5b73  
    692692 
    693693    libvlc.b_stats = config_GetInt( p_vlc, "stats" ); 
     694    libvlc.p_stats = NULL; 
    694695 
    695696    /* 
  • src/misc/hashtables.c

    rf8cac3e r26d5b73  
    219219    } 
    220220 
    221     i_hash += ( i_id << 32 ); 
     221    i_hash += ( (uint64_t)i_id << 32 ); 
    222222 
    223223    return i_hash; 
  • src/misc/stats.c

    r8d995e6 r26d5b73  
    3737static int stats_CounterUpdate( stats_handler_t *p_handler, 
    3838                                counter_t *p_counter, 
    39                                 vlc_value_t val ); 
     39                                vlc_value_t val, vlc_value_t * ); 
    4040static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this ); 
    4141static stats_handler_t *stats_HandlerGet( vlc_object_t *p_this ); 
     
    127127 */ 
    128128int __stats_Update( vlc_object_t *p_this, const char *psz_name, 
    129                     vlc_value_t val
     129                    vlc_value_t val, vlc_value_t *val_new
    130130{ 
    131131    int i_ret; 
     
    152152    } 
    153153 
    154     i_ret = stats_CounterUpdate( p_handler, p_counter, val ); 
     154    i_ret = stats_CounterUpdate( p_handler, p_counter, val, val_new ); 
    155155    vlc_mutex_unlock( &p_handler->object_lock ); 
    156156 
     
    493493static int stats_CounterUpdate( stats_handler_t *p_handler, 
    494494                                counter_t *p_counter, 
    495                                 vlc_value_t val
     495                                vlc_value_t val, vlc_value_t *new_val
    496496{ 
    497497    switch( p_counter->i_compute_type ) 
     
    545545                } 
    546546                p_counter->pp_samples[0]->value = val; 
     547                *new_val = p_counter->pp_samples[0]->value; 
    547548            } 
    548549        } 
     
    597598            { 
    598599            case VLC_VAR_INTEGER: 
     600                p_counter->pp_samples[0]->value.i_int += val.i_int; 
     601                if( new_val ) 
     602                    new_val->i_int = p_counter->pp_samples[0]->value.i_int; 
     603                break; 
    599604            case VLC_VAR_FLOAT: 
    600                 p_counter->pp_samples[0]->value.i_int += val.i_int; 
    601                 break; 
     605                p_counter->pp_samples[0]->value.f_float += val.f_float; 
     606                if( new_val ) 
     607                    new_val->f_float = p_counter->pp_samples[0]->value.f_float; 
    602608            default: 
    603609                msg_Err( p_handler, "Trying to increment invalid variable %s", 
     
    622628static stats_handler_t *stats_HandlerGet( vlc_object_t *p_this ) 
    623629{ 
    624     stats_handler_t *p_handler = (stats_handler_t*) 
    625                           vlc_object_find( p_this->p_vlc, VLC_OBJECT_STATS, 
    626                                            FIND_ANYWHERE ); 
     630    stats_handler_t *p_handler = p_this->p_libvlc->p_stats; 
    627631    if( !p_handler ) 
    628632    { 
     
    632636            return NULL; 
    633637        } 
    634         vlc_object_yield( p_handler ); 
    635     } 
     638    } 
     639    vlc_object_yield( p_handler ); 
    636640    return p_handler; 
    637641} 
     
    658662    } 
    659663    p_handler->i_counters = 0; 
    660     p_handler->p_counters = (hashtable_entry_t *) malloc( 5 * sizeof( variable_t ) ); 
     664    p_handler->p_counters = (hashtable_entry_t *) malloc( 4 * sizeof( variable_t ) ); 
    661665 
    662666    /// \bug is it p_vlc or p_libvlc ? 
    663667    vlc_object_attach( p_handler, p_this->p_vlc ); 
     668 
     669    p_this->p_libvlc->p_stats = p_handler; 
    664670 
    665671    return p_handler; 
  • src/network/httpd.c

    r7b93beb r26d5b73  
    21072107            { 
    21082108                httpd_ClientClean( cl ); 
    2109                 stats_UpdateInteger( host, "active_connections", -1 ); 
     2109                stats_UpdateInteger( host, "active_connections", -1, NULL ); 
    21102110                TAB_REMOVE( host->i_client, host->client, cl ); 
    21112111                free( cl ); 
     
    25612561                    { 
    25622562                        httpd_client_t *cl; 
    2563                         stats_UpdateInteger( host, "client_connections", 1 ); 
    2564                         stats_UpdateInteger( host, "active_connections", 1 ); 
     2563                        stats_UpdateInteger( host, "client_connections", 1, 
     2564                                             NULL ); 
     2565                        stats_UpdateInteger( host, "active_connections", 1, 
     2566                                             NULL ); 
    25652567                        cl = httpd_ClientNew( fd, &sock, i_sock_size, p_tls ); 
    25662568                        p_tls = NULL; 
  • src/stream_output/stream_output.c

    r4efb291 r26d5b73  
    382382        if( p_input ) 
    383383        { 
    384             stats_UpdateInteger( p_input, "sout_sent_packets", 10 ); 
     384            stats_UpdateInteger( p_input, "sout_sent_packets", 10, NULL ); 
    385385            stats_UpdateInteger( p_input, "sout_sent_bytes", 
    386                                  p_access->i_sent_bytes ); 
    387             stats_GetInteger( p_input, 
    388                               p_access->p_parent->p_parent->i_object_id, 
    389                               "sout_sent_bytes", &i_total ); 
    390             stats_UpdateFloat( p_input, "sout_send_bitrate", (float)i_total ); 
    391  
     386                                 p_access->i_sent_bytes, &i_total ); 
     387            stats_UpdateFloat( p_input, "sout_send_bitrate", (float)i_total, 
     388                               NULL ); 
    392389            p_access->i_sent_bytes = 0; 
    393390            vlc_object_release( p_input ); 
  • src/video_output/video_output.c

    rc4fef7e r26d5b73  
    815815                msg_Warn( p_vout, "late picture skipped ("I64Fd")", 
    816816                                  current_date - display_date ); 
    817                 stats_UpdateInteger( p_vout, "lost_pictures", 1 ); 
     817                stats_UpdateInteger( p_vout, "lost_pictures", 1 , NULL); 
    818818                vlc_mutex_unlock( &p_vout->picture_lock ); 
    819819 
     
    838838                    p_vout->i_heap_size--; 
    839839                } 
    840                 stats_UpdateInteger( p_vout, "lost_pictures", 1 ); 
     840                stats_UpdateInteger( p_vout, "lost_pictures", 1, NULL ); 
    841841                msg_Warn( p_vout, "vout warning: early picture skipped " 
    842842                          "("I64Fd")", display_date - current_date 
     
    896896         * Perform rendering 
    897897         */ 
    898         stats_UpdateInteger( p_vout, "displayed_pictures", 1 ); 
     898        stats_UpdateInteger( p_vout, "displayed_pictures", 1, NULL ); 
    899899        p_directbuffer = vout_RenderPicture( p_vout, p_picture, p_subpic ); 
    900900