Skip to content

Commit

Permalink
Limit max async queue size to 250,000 entries
Browse files Browse the repository at this point in the history
  • Loading branch information
gabime committed Jan 18, 2025
1 parent af8440b commit eb660ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions bench/async_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,22 @@ int main(int argc, char *argv[]) {
if (argc > 2) threads = atoi(argv[2]);
if (argc > 3) {
queue_size = atoi(argv[3]);
if (queue_size > 500000) {
spdlog::error("Max queue size allowed: 500,000");
exit(1);
}
}

if (argc > 4) iters = atoi(argv[4]);
// validate all argc values
if (howmany < 1 || threads < 1 || queue_size < 1 || iters < 1) {
if (howmany < 1 || threads < 1 || queue_size < 1 || iters < 1) {
spdlog::error("Invalid input values");
exit(1);
}

constexpr int max_q_size = sinks::async_sink::max_queue_size;
if(queue_size > max_q_size)
{
spdlog::error("Queue size too large. Max queue size is {:L}", max_q_size);
exit(1);
}

auto slot_size = sizeof(details::async_log_msg);
spdlog::info("-------------------------------------------------");
spdlog::info("Messages : {:L}", howmany);
Expand Down
2 changes: 1 addition & 1 deletion include/spdlog/sinks/async_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SPDLOG_API async_sink final : public sink {
discard_new // Discard the log message if the queue is full
};

enum { default_queue_size = 8192, max_queue_size = 10 * 1024 * 1024 };
enum { default_queue_size = 8192, max_queue_size = 250'000};

struct config {
size_t queue_size = default_queue_size;
Expand Down

0 comments on commit eb660ca

Please sign in to comment.