From a26c7c37592487d24751734cb24c08db0135455d Mon Sep 17 00:00:00 2001 From: Borko Jandras Date: Fri, 14 Jul 2023 08:43:03 -0500 Subject: [PATCH] Enabling some assertions in release builds. (#227) --- channel/tcp_channel.cc | 2 +- reducer/aggregation/agg_root_span.cc | 2 +- reducer/ingest/ingest_core.cc | 4 ++-- reducer/ingest/ingest_worker.cc | 4 ++-- reducer/matching/flow_span.cc | 2 +- reducer/reducer.cc | 5 +++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/channel/tcp_channel.cc b/channel/tcp_channel.cc index 959a2955..c000091b 100644 --- a/channel/tcp_channel.cc +++ b/channel/tcp_channel.cc @@ -74,7 +74,7 @@ void TCPChannel::conn_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t u32 res = conn->callbacks_->received_data((u8 *)conn->rx_buffer_, conn->rx_len_); if (res > 0) { - DEBUG_ASSUME(res <= conn->rx_len_); + ASSUME(res <= conn->rx_len_); conn->rx_len_ -= res; memmove(conn->rx_buffer_, (u8 *)conn->rx_buffer_ + res, conn->rx_len_); } diff --git a/reducer/aggregation/agg_root_span.cc b/reducer/aggregation/agg_root_span.cc index 89fb36c5..4106923d 100644 --- a/reducer/aggregation/agg_root_span.cc +++ b/reducer/aggregation/agg_root_span.cc @@ -38,7 +38,7 @@ AggRootSpan::~AggRootSpan() {} void AggRootSpan::update_node( ::ebpf_net::aggregation::weak_refs::agg_root span_ref, u64 timestamp, jsrv_aggregation__update_node *msg) { - DEBUG_ASSUME(msg->side <= 1).else_log("side must be either 0 or 1, instead got {}", msg->side); + ASSUME(msg->side <= 1).else_log("side must be either 0 or 1, instead got {}", msg->side); auto &stat_counters = local_core().stat_counters; diff --git a/reducer/ingest/ingest_core.cc b/reducer/ingest/ingest_core.cc index 0af41015..17f88ddf 100644 --- a/reducer/ingest/ingest_core.cc +++ b/reducer/ingest/ingest_core.cc @@ -71,10 +71,10 @@ IngestCore::IngestCore( } stop_async_.data = this; - DEBUG_ASSUME(ingest_to_logging_queues.num_receivers() == 1).else_log("Not using multiple logging cores"); + ASSUME(ingest_to_logging_queues.num_receivers() == 1).else_log("Not using multiple logging cores"); // Create the ingest workers and start the telemetry TCP server. - DEBUG_ASSUME(ingest_shard_count > 0).else_log("Ingest shards should be > 0, instead got {}", ingest_shard_count); + ASSUME(ingest_shard_count > 0).else_log("Ingest shards should be > 0, instead got {}", ingest_shard_count); std::vector> workers; workers.reserve(ingest_shard_count); diff --git a/reducer/ingest/ingest_worker.cc b/reducer/ingest/ingest_worker.cc index 6edcbf3c..f45fe3d7 100644 --- a/reducer/ingest/ingest_worker.cc +++ b/reducer/ingest/ingest_worker.cc @@ -130,7 +130,7 @@ uint32_t IngestWorker::Callbacks::received_data(const u8 *data, int data_len) } // Increment the begin pointer by the bytes consumed. - DEBUG_ASSUME(static_cast(*bytes_consumed) <= (end - begin)); + ASSUME(static_cast(*bytes_consumed) <= (end - begin)); begin += *bytes_consumed; ++count; @@ -161,7 +161,7 @@ uint32_t IngestWorker::Callbacks::received_data(const u8 *data, int data_len) // Process the decompressed data. begin += consumed_len; - assert(decompressor_active_); + ASSUME(decompressor_active_); const std::optional consumed_uncompressed = received_data_internal(decompressor_.output_buf(), decompressor_.output_buf_size()); diff --git a/reducer/matching/flow_span.cc b/reducer/matching/flow_span.cc index 076639df..9ed3fcde 100644 --- a/reducer/matching/flow_span.cc +++ b/reducer/matching/flow_span.cc @@ -695,7 +695,7 @@ void FlowSpan::http_update(::ebpf_net::matching::weak_refs::flow span_ref, u64 t void FlowSpan::dns_update(::ebpf_net::matching::weak_refs::flow span_ref, u64 timestamp, jsrv_matching__dns_update *msg) { - DEBUG_ASSUME(msg->side <= 1).else_log("side must be either 0 or 1, instead got {}", msg->side); + ASSUME(msg->side <= 1).else_log("side must be either 0 or 1, instead got {}", msg->side); auto const side = u8_to_side(msg->side); auto const is_rx = msg->client_server == (u8)SC_SERVER; // client(0) is 'tx', server(1) is 'rx' diff --git a/reducer/reducer.cc b/reducer/reducer.cc index 9c9bcb37..450c9f6e 100644 --- a/reducer/reducer.cc +++ b/reducer/reducer.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -258,8 +259,8 @@ void Reducer::init_cores() ingest_to_logging_queues_, ingest_to_matching_queues_, config_.telemetry_port); // all writers created - assert(stat_writer_num == num_stat_writers); - assert(!prom_metrics_publisher_ || prom_metric_writer_num == num_prom_metric_writers); + ASSUME(stat_writer_num == num_stat_writers); + ASSUME(!prom_metrics_publisher_ || prom_metric_writer_num == num_prom_metric_writers); } void Reducer::start_threads()