Voting: std.logger

Kevin Lamonte via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 6 12:41:52 PDT 2014


On Wednesday, 3 September 2014 at 13:13:31 UTC, Ola Fosheim 
Grøstad wrote:

> If you accept slightly out of sync logging then you can have 
> thread local buffers and on x86 use the command RDTSC which 
> gives you a (good enough) timer value so you can merge the 
> buffers from threads later. It takes roughly 20-30 cycles which 
> I presume is better than CAS instructions, or you can just 
> write directly to a global counter without CAS and accept that 
> it jitters?

Since we are talking about performance, I did some tests and 
found to my surprise that ~95% of the time consumed in a log call 
is Clock.currTime's call to clock_gettime().  I submitted a 
report for it (https://issues.dlang.org/show_bug.cgi?id=13433), 
but it also brings up how to expose it in the std.logger API.

The API automatically grabs thisTid and Clock.currTime during 
construction of the LogEntry (plus it should also grab 
Thread.getThis and Fiber.getThis).  Should this behavior be 
modifiable by clients, by subclasses, or neither?  If so, how?


More information about the Digitalmars-d mailing list