-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from odygrd/bounded_queue
add bounded queue blocking and transit event soft and hard limits
- Loading branch information
Showing
26 changed files
with
984 additions
and
531 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
add_executable(BENCHMARK_quill_backend_throughput quill_backend_throughput.cpp) | ||
target_link_libraries(BENCHMARK_quill_backend_throughput quill) | ||
|
||
add_executable(BENCHMARK_quill_backend_throughput_no_buffering quill_backend_throughput_no_buffering.cpp) | ||
target_link_libraries(BENCHMARK_quill_backend_throughput_no_buffering quill) |
53 changes: 53 additions & 0 deletions
53
benchmarks/backend_throughput/quill_backend_throughput_no_buffering.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "quill/Quill.h" | ||
#include <chrono> | ||
#include <iostream> | ||
|
||
static constexpr size_t total_iterations = 4'000'000; | ||
|
||
/** | ||
* The backend worker just spins, so we just measure the total time elapsed for total_iterations | ||
*/ | ||
int main() | ||
{ | ||
// main thread affinity | ||
quill::detail::set_cpu_affinity(0); | ||
|
||
quill::Config cfg; | ||
cfg.backend_thread_yield = false; | ||
cfg.backend_thread_cpu_affinity = 1; | ||
cfg.backend_thread_use_transit_buffer = false; | ||
|
||
quill::configure(cfg); | ||
|
||
// Start the logging backend thread and give it some tiem to init | ||
quill::start(); | ||
std::this_thread::sleep_for(std::chrono::milliseconds{100}); | ||
|
||
// Create a file handler to write to a file | ||
quill::Handler* file_handler = quill::file_handler("quill_backend_total_time.log", "w"); | ||
file_handler->set_pattern("%(ascii_time) [%(thread)] %(fileline) %(level_name) %(message)"); | ||
quill::Logger* logger = quill::create_logger("bench_logger", file_handler); | ||
quill::preallocate(); | ||
|
||
// start counting the time until backend worker finishes | ||
auto const start_time = std::chrono::steady_clock::now(); | ||
for (size_t iteration = 0; iteration < total_iterations; ++iteration) | ||
{ | ||
LOG_INFO(logger, "Iteration: {} int: {} double: {}", iteration, iteration * 2, | ||
static_cast<double>(iteration) / 2); | ||
} | ||
|
||
// block until all messages are flushed | ||
quill::flush(); | ||
|
||
auto const end_time = std::chrono::steady_clock::now(); | ||
auto const delta = end_time - start_time; | ||
auto delta_d = std::chrono::duration_cast<std::chrono::duration<double>>(delta).count(); | ||
|
||
std::cout << fmt::format( | ||
"Throughput is {:.2f} million msgs/sec average, total time elapsed: {} ms for {} " | ||
"log messages \n", | ||
total_iterations / delta_d / 1e6, | ||
std::chrono::duration_cast<std::chrono::milliseconds>(delta).count(), total_iterations) | ||
<< std::endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// ALWAYS define QUILL_USE_BOUNDED_BLOCKING_QUEUE before including quill. | ||
// A better option is to ALWAYS pass this flag when you are building e.g in CMake target_compile_definitions(<target> PUBLIC QUILL_USE_BOUNDED_BLOCKING_QUEUE) | ||
#define QUILL_USE_BOUNDED_BLOCKING_QUEUE | ||
|
||
#include "quill/Quill.h" | ||
|
||
int main() | ||
{ | ||
quill::Handler* handler = quill::stdout_handler(); /** for stdout **/ | ||
// quill::Handler* handler = quill::file_handler("quickstart.log", "w"); /** for writing to file **/ | ||
handler->set_pattern("%(ascii_time) [%(thread)] %(fileline:<28) LOG_%(level_name) %(message)"); | ||
|
||
// set configuration | ||
quill::Config cfg; | ||
cfg.default_handlers.push_back(handler); | ||
|
||
// to simulate message blocking easily we can to set a high sleep duration to the logging thread | ||
cfg.backend_thread_sleep_duration = std::chrono::seconds{1}; | ||
|
||
// and a small queue size | ||
cfg.default_queue_capacity = 4'096; | ||
|
||
// Apply configuration and start the backend worker thread | ||
quill::configure(cfg); | ||
quill::start(); | ||
|
||
for (size_t i = 0; i < 1000; ++i) | ||
{ | ||
LOG_INFO(quill::get_logger(), "Hello {} #{}", "world", i); | ||
LOG_ERROR(quill::get_logger(), "This is a log error example {} #{}", 7, i); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// ALWAYS define QUILL_USE_BOUNDED_QUEUE before including quill. | ||
// A better option is to ALWAYS pass this flag when you are building e.g in CMake target_compile_definitions(<target> PUBLIC QUILL_USE_BOUNDED_QUEUE) | ||
#define QUILL_USE_BOUNDED_QUEUE | ||
|
||
#include "quill/Quill.h" | ||
|
||
int main() | ||
{ | ||
quill::Handler* handler = quill::stdout_handler(); /** for stdout **/ | ||
// quill::Handler* handler = quill::file_handler("quickstart.log", "w"); /** for writing to file **/ | ||
handler->set_pattern("%(ascii_time) [%(thread)] %(fileline:<28) LOG_%(level_name) %(message)"); | ||
|
||
// set configuration | ||
quill::Config cfg; | ||
cfg.default_handlers.push_back(handler); | ||
|
||
// to simulate message dropping easily we can to set a high sleep duration to the logging thread | ||
cfg.backend_thread_sleep_duration = std::chrono::seconds{1}; | ||
|
||
// and a small queue size | ||
cfg.default_queue_capacity = 4'096; | ||
|
||
// Apply configuration and start the backend worker thread | ||
quill::configure(cfg); | ||
quill::start(); | ||
|
||
for (size_t i = 0; i < 1000; ++i) | ||
{ | ||
LOG_INFO(quill::get_logger(), "Hello {} #{}", "world", i); | ||
LOG_ERROR(quill::get_logger(), "This is a log error example {} #{}", 7, i); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.