fast way to infer caller
Ceki Gülcü
ceki at qos.ch
Thu Apr 7 13:38:25 UTC 2022
Rémi, Jason, Steven, Kasper,
Thank you all for your thoughtful feedback.
I forgot to mention that in addition to obtaining the appropriate logger
by inferring caller class, the caller class may also be a data point
written with each logging event, aka LogRecord.
If the cost of writing a log event to file is 500 nanoseconds (without
caller data), spending additional 1800 nanoseconds to obtain caller data
via StackWalker reduces throughput by a factor of 4.8. Mind you, this is
still much better than obtaining caller data via "new
Throwable().getStackTrace();" which costs about 11'000 nanoseconds,
reducing throughput by a factor of 24.
While logging 2'000'000 messages per second is not a goal, reducing the
cost of logging as much as possible, is a worthwhile goal. At present
time, retrieving caller data still has a significant effect on logging
performance.
--
Ceki Gülcü
Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch
More information about the core-libs-dev
mailing list