epggrab: tuning and optimizations

- reduce timeout value for nit to 240
- increase interval value for nit to 3600
- process all waiting muxes in one shot
- add the grace value for satellite positioners
This commit is contained in:
Jaroslav Kysela 2014-05-14 08:35:04 +02:00
parent b773a41b4e
commit b0364fb4b2
5 changed files with 36 additions and 21 deletions

View file

@ -573,7 +573,7 @@ _eit_callback
/* Register interest */
if (tableid >= 0x50)
ota = epggrab_ota_register((epggrab_module_ota_t*)mod, mm, 1200, 3600);
ota = epggrab_ota_register((epggrab_module_ota_t*)mod, mm, 3600, 240);
/* Begin */
r = dvb_table_begin(mt, ptr, len, tableid, extraid, 11, &st, &sect, &last, &ver);

View file

@ -60,11 +60,11 @@ om_id_cmp ( epggrab_ota_mux_t *a, epggrab_ota_mux_t *b )
return strcmp(a->om_mux_uuid, b->om_mux_uuid);
}
#define EPGGRAB_OTA_MIN_PERIOD 600
#define EPGGRAB_OTA_MIN_PERIOD 300
#define EPGGRAB_OTA_MIN_TIMEOUT 30
static int
epggrab_ota_period ( epggrab_ota_mux_t *ota )
epggrab_ota_period ( epggrab_ota_mux_t *ota, int divider )
{
int period = 0;
epggrab_ota_map_t *map;
@ -77,6 +77,8 @@ epggrab_ota_period ( epggrab_ota_mux_t *ota )
period = map->om_interval;
}
period /= divider;
if (period < EPGGRAB_OTA_MIN_PERIOD)
period = EPGGRAB_OTA_MIN_PERIOD;
@ -110,7 +112,7 @@ epggrab_ota_done ( epggrab_ota_mux_t *ota, int timeout )
LIST_REMOVE(ota, om_q_link);
ota->om_active = 0;
ota->om_when = dispatch_clock + epggrab_ota_period(ota);
ota->om_when = dispatch_clock + epggrab_ota_period(ota, 1);
LIST_INSERT_SORTED(&epggrab_ota_pending, ota, om_q_link, om_time_cmp);
/* Remove subscriber */
@ -128,10 +130,10 @@ epggrab_ota_done ( epggrab_ota_mux_t *ota, int timeout )
}
static void
epggrab_ota_start ( epggrab_ota_mux_t *om )
epggrab_ota_start ( epggrab_ota_mux_t *om, int grace )
{
epggrab_ota_map_t *map;
om->om_when = dispatch_clock + epggrab_ota_timeout(om);
om->om_when = dispatch_clock + epggrab_ota_timeout(om) + grace;
om->om_active = 1;
LIST_INSERT_SORTED(&epggrab_ota_active, om, om_q_link, om_time_cmp);
if (LIST_FIRST(&epggrab_ota_active) == om)
@ -242,6 +244,7 @@ epggrab_ota_complete
{
int done = 1;
epggrab_ota_map_t *map;
lock_assert(&global_lock);
tvhdebug(mod->id, "grab complete");
/* Test for completion */
@ -292,15 +295,18 @@ epggrab_ota_pending_timer_cb ( void *p )
epggrab_ota_map_t *map;
epggrab_ota_mux_t *om = LIST_FIRST(&epggrab_ota_pending);
mpegts_mux_t *mm;
int extra = 0;
gtimer_disarm(&epggrab_ota_pending_timer);
lock_assert(&global_lock);
if (!om)
return;
/* Double check */
if (om->om_when > dispatch_clock)
goto done;
next_one:
LIST_REMOVE(om, om_q_link);
/* Find the mux */
@ -326,31 +332,31 @@ epggrab_ota_pending_timer_cb ( void *p )
char name[256];
mm->mm_display_name(mm, name, sizeof(name));
tvhdebug("epggrab", "no modules attached to %s, check again later", name);
om->om_when = dispatch_clock + epggrab_ota_period(om) / 2;
om->om_when = dispatch_clock + epggrab_ota_period(om, 4);
LIST_INSERT_SORTED(&epggrab_ota_pending, om, om_q_link, om_time_cmp);
goto done;
}
/* Insert into active (assume success) */
// Note: if we don't do this the subscribe below can result in a mux
// start call which means we call it a second time below
epggrab_ota_start(om);
/* Subscribe to the mux */
if (mpegts_mux_subscribe(mm, "epggrab", SUBSCRIPTION_PRIO_EPG)) {
LIST_REMOVE(om, om_q_link);
om->om_active = 0;
om->om_when = dispatch_clock + epggrab_ota_period(om) / 2;
om->om_when = dispatch_clock + epggrab_ota_period(om, 4) + extra;
LIST_INSERT_SORTED(&epggrab_ota_pending, om, om_q_link, om_time_cmp);
} else {
epggrab_mux_start0(mm, 1);
mpegts_mux_instance_t *mmi = mm->mm_active;
epggrab_ota_start(om, mpegts_input_grace(mmi->mmi_input, mm));
}
done:
om = LIST_FIRST(&epggrab_ota_pending);
if (om)
if (om) {
if (om->om_when <= dispatch_clock) {
extra += 60; /* differentiate the mux busy requests */
goto next_one;
}
gtimer_arm_abs(&epggrab_ota_pending_timer, epggrab_ota_pending_timer_cb,
NULL, om->om_when);
}
}
/* **************************************************************************

View file

@ -574,6 +574,8 @@ void mpegts_input_close_service ( mpegts_input_t *mi, mpegts_service_t *s );
void mpegts_input_status_timer ( void *p );
int mpegts_input_grace ( mpegts_input_t * mi, mpegts_mux_t * mm );
/* TODO: exposing these class methods here is a bit of a hack */
const void *mpegts_input_class_network_get ( void *o );
int mpegts_input_class_network_set ( void *o, const void *p );

View file

@ -1047,6 +1047,16 @@ mpegts_input_set_networks ( mpegts_input_t *mi, htsmsg_t *msg )
return save;
}
int mpegts_input_grace( mpegts_input_t *mi, mpegts_mux_t *mm )
{
/* Get timeout */
int t = 0;
if (mi && mi->mi_get_grace)
t = mi->mi_get_grace(mi, mm);
if (t < 5) t = 5; // lower bound
return t;
}
/******************************************************************************
* Editor Configuration
*

View file

@ -92,10 +92,7 @@ mpegts_mux_add_to_current
mm_initial_scan_link);
/* Get timeout */
t = 0;
if (mi && mi->mi_get_grace)
t = mi->mi_get_grace(mi, mm);
if (t < 5) t = 5; // lower bound
t = mpegts_input_grace(mi, mm);
/* Setup timeout */
gtimer_arm(&mm->mm_initial_scan_timeout,