latency
Is sync faster than async? I can't understand,Isn't asynchronous supposed to be faster than synchronous?
Short answer: async cannot usually be faster than sync
Long answer: most async operations are implemented by requesting a task to another thread. In this case, async cannot be faster than sync because of the cost of passing data to another thread.. However, the thread that requests a task to another thread can proceed to the next operation without waiting for the task to complete, so the next operation can start earlier than sync.
See also: https://stackoverflow.com/questions/29981941/why-is-async-programming-faster
Thanks for your answer When people use async logger, they hope that it does not affect the latency of the main thread so that the next operation can be started earlier, however, this effect cannot be achieved by using spdlog::async_logger
If the function “SPDLOG_LOGGER_WARN(async_logger, "")” returned earlier, that would be great
I think the existing async_logger is primarily used to ensure that the main thread is not blocked,but passing data to queue is not very fast
The async_logger is intended to avoid I/O latency, and as explained before, there will be additional costs for requesting tasks to different threads, which cannot be avoided.