Skip to content

File Sink and Async programs #57

Answered by SpriteOvO
gwbres asked this question in Q&A
Discussion options

You must be logged in to vote

tl;dr: You don't have to use AsyncPoolSink if you are just writing log to file (with not very verbose flush_level_filter value).


Full explanation

For file sinks, the bottleneck will not be happening on the Arc (accessing a Arc is almost zero-cost, just one more indirect pointer access), but will be in the internal locks for writing data to std::fs::File.

To avoid this bottleneck by default, spdlog-rs has already wrapped the File object with std::io::BufWriter. The effect of this behavior is that data writes are not actually performed to the filesystem, but are cached in the BufWriter until the buffer is full or flushed explicitly.

(Tip: Explicit flushes can be performed by manually calling

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gwbres
Comment options

Answer selected by gwbres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants