Re:NanoLog – a nanosecond scale logging system for C++
by Matthias247 on Sunday September 01, 2019 @10:41PM
(#20856402)
Yes, but you need to have a location where to copy them to. They can’t be on the stack, since the logging task runs asynchronously. So each captured argument must be in some form heap allocated. Eg passing 2 strings as arguments and one integer might require 3 additional heap allocation - where the malloc/free overhead might outweigh the string formatting costs. You can try to optimize here with specialized allocators (eg Arenas) or trying to generate dedicated structures for each logging callsite where all arguments can be carried inside a single heap allocated struct (instead of 3 here). But that might lead to other disadvantages - eg code bloat.
[ Parent
| on HN ]
Re:NanoLog – a nanosecond scale logging system for C++
by gpderetta on Monday September 02, 2019 @03:48AM
(#20857441)
That would be a terrible implementation strategy. You would simply copy each argument into the communication ring buffer. You can also use specialised strategies for some types, for example string contents can be transmitted inline instead of copying the strings themselves.
Re:NanoLog – a nanosecond scale logging system for C++
by RafaGC on Monday September 02, 2019 @01:48AM
(#20857026)
On my logger the thread queue was(is) node based, so it was just a matter of making a bigger contiguous allocation and placing things there contiguously, the log entry and the data copies. 1 allocation.
Re:NanoLog – a nanosecond scale logging system for C++
by paulddraper on Sunday September 01, 2019 @11:43PM
(#20856629)
Good point