Skip to content

Commit

Permalink
Enabling some assertions in release builds. (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjandras committed Jul 14, 2023
1 parent 8f04e6d commit a26c7c3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion channel/tcp_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand Down
2 changes: 1 addition & 1 deletion reducer/aggregation/agg_root_span.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<AggCore>().stat_counters;

Expand Down
4 changes: 2 additions & 2 deletions reducer/ingest/ingest_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::unique_ptr<IngestWorker>> workers;
workers.reserve(ingest_shard_count);
Expand Down
4 changes: 2 additions & 2 deletions reducer/ingest/ingest_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(*bytes_consumed) <= (end - begin));
ASSUME(static_cast<int>(*bytes_consumed) <= (end - begin));
begin += *bytes_consumed;
++count;

Expand Down Expand Up @@ -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<uint32_t> consumed_uncompressed =
received_data_internal(decompressor_.output_buf(), decompressor_.output_buf_size());

Expand Down
2 changes: 1 addition & 1 deletion reducer/matching/flow_span.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 3 additions & 2 deletions reducer/reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <util/boot_time.h>
#include <util/debug.h>
#include <util/environment_variables.h>
#include <util/error_handling.h>
#include <util/file_ops.h>
#include <util/log.h>
#include <util/uv_helpers.h>
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a26c7c3

Please sign in to comment.