summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/single_threaded_scheduler.cc
diff options
context:
space:
mode:
authorAndy Walls <awalls.cx18@gmail.com>2017-12-11 19:25:01 -0500
committerMartin Braun <martin.braun@ettus.com>2018-02-03 14:23:32 +0100
commiteee29fbe8ff4c58ae68af89384328f23f0a8e7b6 (patch)
tree35c9a212e0dfc2dbcf2cc3d01ef8e40bf22244c0 /gnuradio-runtime/lib/single_threaded_scheduler.cc
parentb0912d31f1a2cfea93a5588898cae0c652cd89d4 (diff)
gnuradio-runtime: Optimize some buffer[_reader]_sptr grabs and releases
Optimize some reference counted buffer[_reader]_sptr grabs and releases that show up as minor CPU wasters in profiling when there are a lot of tags or some blocks that "return 0" often. At high sample rates (e.g. 160 Msps), this can save ~2% CPU on blocks that propagate a fair number of tags.
Diffstat (limited to 'gnuradio-runtime/lib/single_threaded_scheduler.cc')
-rw-r--r--gnuradio-runtime/lib/single_threaded_scheduler.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/gnuradio-runtime/lib/single_threaded_scheduler.cc b/gnuradio-runtime/lib/single_threaded_scheduler.cc
index c86d26ca3a..a85f390a30 100644
--- a/gnuradio-runtime/lib/single_threaded_scheduler.cc
+++ b/gnuradio-runtime/lib/single_threaded_scheduler.cc
@@ -112,9 +112,10 @@ namespace gr {
int min_space = std::numeric_limits<int>::max();
for(int i = 0; i < d->noutputs (); i++) {
- int n = round_down (d->output(i)->space_available (), output_multiple);
+ buffer_sptr out_buf = d->output(i);
+ int n = round_down (out_buf->space_available (), output_multiple);
if(n == 0) { // We're blocked on output.
- if(d->output(i)->done()) { // Downstream is done, therefore we're done.
+ if(out_buf->done()) { // Downstream is done, therefore we're done.
return -1;
}
return 0;
@@ -201,9 +202,10 @@ namespace gr {
max_items_avail = 0;
for(int i = 0; i < d->ninputs (); i++) {
- ninput_items[i] = d->input(i)->items_available();
- //if (ninput_items[i] == 0 && d->input(i)->done())
- if(ninput_items[i] < m->output_multiple() && d->input(i)->done())
+ buffer_reader_sptr in_buf = d->input(i);
+ ninput_items[i] = in_buf->items_available();
+ //if (ninput_items[i] == 0 && in_buf->done())
+ if(ninput_items[i] < m->output_multiple() && in_buf->done())
goto were_done;
max_items_avail = std::max (max_items_avail, ninput_items[i]);
@@ -294,12 +296,13 @@ namespace gr {
}
// We're blocked on input
+ buffer_reader_sptr in_buf = d->input(i);
LOG(*d_log << " BLKD_IN\n");
- if(d->input(i)->done()) // If the upstream block is done, we're done
+ if(in_buf->done()) // If the upstream block is done, we're done
goto were_done;
// Is it possible to ever fulfill this request?
- if(ninput_items_required[i] > d->input(i)->max_possible_items_available ()) {
+ if(ninput_items_required[i] > in_buf->max_possible_items_available ()) {
// Nope, never going to happen...
std::cerr << "\nsched: <block " << m->name()
<< " (" << m->unique_id() << ")>"
@@ -308,7 +311,7 @@ namespace gr {
<< " ninput_items_required = "
<< ninput_items_required[i] << "\n"
<< " max_possible_items_available = "
- << d->input(i)->max_possible_items_available() << "\n"
+ << in_buf->max_possible_items_available() << "\n"
<< " If this is a filter, consider reducing the number of taps.\n";
goto were_done;
}