Skip to content

Commit

Permalink
log for long flush
Browse files Browse the repository at this point in the history
  • Loading branch information
BLuedtke committed Nov 29, 2024
1 parent 00a3638 commit 45c86b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/transmission/bidib_transmission_receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,9 @@ static void bidib_split_packet(const uint8_t *const buffer, size_t buffer_size)
syslog_libbidib(LOG_WARNING,
"bidib_split_packet took longer than threshold %llu us for message of type %s",
slow_processing_threshold_us, bidib_message_string_mapping[type]);
syslog_libbidib(LOG_WARNING, "bidib_split_packet msg-read-in: %llu us\n", msg_read_in_us);
syslog_libbidib(LOG_WARNING, "bidib_split_packet node-update: %llu us\n", node_update_us);
syslog_libbidib(LOG_WARNING, "bidib_split_packet handle-receive: %llu us\n", handle_receive_us);
syslog_libbidib(LOG_WARNING, "bidib_split_packet msg-read-in: %llu us", msg_read_in_us);
syslog_libbidib(LOG_WARNING, "bidib_split_packet node-update: %llu us", node_update_us);
syslog_libbidib(LOG_WARNING, "bidib_split_packet handle-receive: %llu us", handle_receive_us);
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/transmission/bidib_transmission_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ static void bidib_flush_impl_old(void) {
*
*/
static void bidib_flush_impl(void) {
struct timespec start, end1, end2;

clock_gettime(CLOCK_MONOTONIC_RAW, &start);
if (buffer_index > 0) {
uint8_t crc = 0;
int32_t aux_index = 0;
Expand Down Expand Up @@ -164,7 +167,17 @@ static void bidib_flush_impl(void) {

buffer_index = 0;
}
clock_gettime(CLOCK_MONOTONIC_RAW, &end1);
syslog_libbidib(LOG_DEBUG, "%s", "Cache flushed");
clock_gettime(CLOCK_MONOTONIC_RAW, &end2);
uint64_t flush_us = (end1.tv_sec - start.tv_sec) * 1000000 + (end1.tv_nsec - start.tv_nsec) / 1000;
uint64_t log_us = (end2.tv_sec - end1.tv_sec) * 1000000 + (end2.tv_nsec - end1.tv_nsec) / 1000;
// longer than 0.01s
if (flush_us + log_us > 10000) {
syslog_libbidib(LOG_WARNING, "bidib_flush_impl took longer than 10000 us");
syslog_libbidib(LOG_WARNING, " Flushing took %llu us", flush_us);
syslog_libbidib(LOG_WARNING, "Logging debug took %llu us", log_us);
}
}

void bidib_flush(void) {
Expand Down

0 comments on commit 45c86b7

Please sign in to comment.