1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-04 23:40:04 +00:00

gnss_synchro_monitor: reduce CPU consumption

For some unknown reason gnss_synchro_monitor stays in a tight loop trying
to catch all syncros and sometimes consumes the whole CPU core.
Triggering the gnss_syncro_monitor from sample counter as it is done
with observables greatly reduces CPU usage from ~60...90% to <1%.

Signed-off-by: Vladislav P <vladisslav2011@gmail.com>
This commit is contained in:
Vladislav P 2022-09-07 07:24:46 +03:00
parent f09da3ded6
commit 1a6efcac0a
No known key found for this signature in database
GPG Key ID: 631C5FD38EE8D868
2 changed files with 8 additions and 3 deletions

View File

@ -55,11 +55,13 @@ gnss_synchro_monitor::gnss_synchro_monitor(int n_channels,
void gnss_synchro_monitor::forecast(int noutput_items __attribute__((unused)), gr_vector_int& ninput_items_required)
{
for (int32_t channel_index = 0; channel_index < d_nchannels; channel_index++)
for (int32_t channel_index = 0; channel_index < d_nchannels - 1; channel_index++)
{
// Set the required number of inputs to 0 so that a lone input on any channel can be pushed to UDP
ninput_items_required[channel_index] = 0;
}
// last input channel is the sample counter, triggered each ms
ninput_items_required[d_nchannels - 1] = 1;
}
@ -70,7 +72,7 @@ int gnss_synchro_monitor::general_work(int noutput_items __attribute__((unused))
const auto** in = reinterpret_cast<const Gnss_Synchro**>(&input_items[0]);
// Loop through each input stream channel
for (int channel_index = 0; channel_index < d_nchannels; channel_index++)
for (int channel_index = 0; channel_index < d_nchannels - 1; channel_index++)
{
// Loop through each item in each input stream channel
int count = 0;
@ -91,6 +93,7 @@ int gnss_synchro_monitor::general_work(int noutput_items __attribute__((unused))
}
}
}
consume(d_nchannels - 1, ninput_items[d_nchannels - 1]);
// Not producing any outputs
return 0;

View File

@ -206,7 +206,8 @@ void GNSSFlowgraph::init()
udp_addr_vec.erase(std::unique(udp_addr_vec.begin(), udp_addr_vec.end()), udp_addr_vec.end());
// Instantiate monitor object
GnssSynchroMonitor_ = gnss_synchro_make_monitor(channels_count_,
// last input channel is the sample counter, triggered each ms
GnssSynchroMonitor_ = gnss_synchro_make_monitor(channels_count_ + 1,
configuration_->property("Monitor.decimation_factor", 1),
configuration_->property("Monitor.udp_port", 1234),
udp_addr_vec, enable_protobuf);
@ -1216,6 +1217,7 @@ int GNSSFlowgraph::connect_gnss_synchro_monitor()
{
top_block_->connect(observables_->get_right_block(), i, GnssSynchroMonitor_, i);
}
top_block_->connect(ch_out_sample_counter_, 0, GnssSynchroMonitor_, channels_count_); // extra port for the sample counter pulse
}
catch (const std::exception& e)
{