www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18388] New: std.experimental.logger slow performance

https://issues.dlang.org/show_bug.cgi?id=18388

          Issue ID: 18388
           Summary: std.experimental.logger slow performance
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: aruncxy gmail.com

std.experimental.logger is very slow when compared to some implementation in
C++ (spdlog)

From my initial observations, the max CPU usage per thread doesn't exceed 30%
on average. 07-02-2018 00:09:00 vaalaham ~/code/cpp/spdlog/bench $ make >/dev/null 2>&1 && time ./spdlog-bench-mt 8 real 0m0.562s user 0m1.480s sys 0m1.620s 07-02-2018 00:09:05 vaalaham ~/code/cpp/spdlog/bench $ 07-02-2018 00:09:26 vaalaham ~/code/d/std-log-benchmark $ time ./std-log-benchmark 8 1000000 real 0m5.617s user 0m4.048s sys 0m3.674s 07-02-2018 00:09:34 vaalaham ~/code/d/std-log-benchmark $ import core.atomic; import core.thread; import std.parallelism; import std.experimental.logger; import std.stdio; import std.conv : to; shared int msgCounter = 0; shared int maxCount = 1_000_000; __gshared FileLogger _logger; void main(string[] args) { if (args.length != 3) { writefln("Usage: %s <thread-count> <loop-count>", args[0]); return; } _logger = new FileLogger("/dev/null", LogLevel.trace); const threadCount = to!int(args[1]); maxCount = to!int(args[2]) - threadCount; auto pool = new TaskPool(threadCount); foreach (tid; 0 .. threadCount) pool.put(task!logMe(tid + 1)); pool.finish; } void logMe(const int tid) { while (true) { pleasure", tid, atomicOp!"+="(msgCounter, 1)); if (atomicLoad(msgCounter) > maxCount) break; } } --
Feb 07 2018