void TimesliceBuilderZeromq::report_status() {
  constexpr auto interval = std::chrono::seconds(1);

  std::chrono::system_clock::time_point now = std::chrono::system_clock::now();

  // FIXME: dummy code here...
  auto& c = connections_.at(0);
  BufferStatus status_desc{now, c->desc.size(), acked_, acked_, tpos_};
  BufferStatus status_data{now, c->desc.size(), acked_, acked_, tpos_};

  /*
  double delta_t =
      std::chrono::duration<double, std::chrono::seconds::period>(
          status_desc.time - previous_buffer_status_desc_.time)
          .count();
  double rate_desc = static_cast<double>(status_desc.acked -
                                         previous_buffer_status_desc_.acked) /
                     delta_t;
  double rate_data = static_cast<double>(status_data.acked -
                                         previous_buffer_status_data_.acked) /
                     delta_t;
  */

  L_(debug) << "[c" << compute_index_ << "] desc " << status_desc.percentages()
            << " (used..free) | "
            << human_readable_count(status_desc.acked, true, "")
            << " timeslices";

  L_(debug) << "[c" << compute_index_ << "] data " << status_data.percentages()
            << " (used..free) | "
            << human_readable_count(status_data.acked, true);

  L_(info) << "[c" << compute_index_ << "] |"
           << bar_graph(status_data.vector(), "#._", 20) << "|"
           << bar_graph(status_desc.vector(), "#._", 10) << "| ";

  previous_buffer_status_desc_ = status_desc;
  previous_buffer_status_data_ = status_data;

  scheduler_.add(std::bind(&TimesliceBuilderZeromq::report_status, this),
                 now + interval);
}
Example #2
0
void InputChannelSender::report_status()
{
    constexpr auto interval = std::chrono::seconds(1);

    // if data_source.written pointers are lagging behind due to lazy updates,
    // use sent value instead
    uint64_t written_desc = data_source_.get_write_index().desc;
    if (written_desc < sent_desc_) {
        written_desc = sent_desc_;
    }
    uint64_t written_data = data_source_.get_write_index().data;
    if (written_data < sent_data_) {
        written_data = sent_data_;
    }

    std::chrono::system_clock::time_point now =
        std::chrono::system_clock::now();
    SendBufferStatus status_desc{now,
                                 data_source_.desc_buffer().size(),
                                 cached_acked_desc_,
                                 acked_desc_,
                                 sent_desc_,
                                 written_desc};
    SendBufferStatus status_data{now,
                                 data_source_.data_buffer().size(),
                                 cached_acked_data_,
                                 acked_data_,
                                 sent_data_,
                                 written_data};

    double delta_t =
        std::chrono::duration<double, std::chrono::seconds::period>(
            status_desc.time - previous_send_buffer_status_desc_.time)
            .count();
    double rate_desc =
        static_cast<double>(status_desc.acked -
                            previous_send_buffer_status_desc_.acked) /
        delta_t;
    double rate_data =
        static_cast<double>(status_data.acked -
                            previous_send_buffer_status_data_.acked) /
        delta_t;

    L_(debug) << "[i" << input_index_ << "] desc " << status_desc.percentages()
              << " (used..free) | "
              << human_readable_count(status_desc.acked, true, "") << " ("
              << human_readable_count(rate_desc, true, "Hz") << ")";

    L_(debug) << "[i" << input_index_ << "] data " << status_data.percentages()
              << " (used..free) | "
              << human_readable_count(status_data.acked, true) << " ("
              << human_readable_count(rate_data, true, "B/s") << ")";

    L_(info) << "[i" << input_index_ << "]   |"
             << bar_graph(status_data.vector(), "#x._", 20) << "|"
             << bar_graph(status_desc.vector(), "#x._", 10) << "| "
             << human_readable_count(rate_data, true, "B/s") << " ("
             << human_readable_count(rate_desc, true, "Hz") << ")";

    previous_send_buffer_status_desc_ = status_desc;
    previous_send_buffer_status_data_ = status_data;

    scheduler_.add(std::bind(&InputChannelSender::report_status, this),
                   now + interval);
}