Skip to content

Commit

Permalink
gnss_synchro_monitor: reduce CPU consumption
Browse files Browse the repository at this point in the history
For some unknown reaso 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>
  • Loading branch information
vladisslav2011 committed Sep 6, 2022
1 parent 45e1fa3 commit 7ed3241
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/core/monitor/gnss_synchro_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ 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;
}
ninput_items_required[d_nchannels - 1] = 1;
}


Expand All @@ -70,7 +71,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;
Expand All @@ -91,6 +92,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;
Expand Down
3 changes: 2 additions & 1 deletion src/core/receiver/gnss_flowgraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ 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_,
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);
Expand Down Expand Up @@ -850,6 +850,7 @@ int GNSSFlowgraph::connect_sample_counter()
ch_out_sample_counter_ = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0));
top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter_, 0);
top_block_->connect(ch_out_sample_counter_, 0, observables_->get_left_block(), channels_count_); // extra port for the sample counter pulse
top_block_->connect(ch_out_sample_counter_, 0, GnssSynchroMonitor_, channels_count_); // extra port for the sample counter pulse
}
catch (const std::exception& e)
{
Expand Down

0 comments on commit 7ed3241

Please sign in to comment.