logging: reduce the amount of code emitted for log statements
authorAdam Simpkins <simpkins@fb.com>
Wed, 21 Jun 2017 02:44:20 +0000 (19:44 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 21 Jun 2017 02:50:54 +0000 (19:50 -0700)
commitfc91e3033ab178ae85b54594f7dd09594de19b57
tree0835d511e01ad062651e8161334c67aca1621bd0
parentcf984921c268141c3cf5174e27ad3e62e3614151
logging: reduce the amount of code emitted for log statements

Summary:
This refactors the logging code with the aim of reducing the amount of assembly
code emitted for each log statement, particularly for `XLOG()` statements.
Ideally it should be possible to put debug `XLOG()` statements throughout your
code without having to worry about the performance overhead.  Therefore we
should attempt to make sure that `XLOG()` statements do not generate a lot of
assembly and hurt icache performance.

This diff does not have any code behavior changes--it just moves code around a
bit.  The high-level summary is:

- Move as much code as possible into the LogStreamProcessor constructors and
  destructor.  Make sure these methods are defined in LogStreamProcessor.cpp to
  avoid having them be emitted inline at each log statement.
- Move some of the XLOG level checking logic into separate non-inline functions
  defined in xlog.cpp
- Pass xlog category information around as a pair of (categoryName,
  isOverridden) parameters.  If isOverridden is true then the categoryName
  parameter should be used as the category name directly.  If isOverridden is
  false, then categoryName is a filename that needs to go through filename to
  category name string processing.  This allows the category name processing to
  be done in non-inlined code.

Reviewed By: wez

Differential Revision: D5269976

fbshipit-source-id: 7a7877ddfed66cd27ed82f052330b6aa2be4b37b
folly/experimental/logging/LogStream.cpp
folly/experimental/logging/LogStream.h
folly/experimental/logging/LogStreamProcessor.cpp
folly/experimental/logging/LogStreamProcessor.h
folly/experimental/logging/Logger.h
folly/experimental/logging/test/LogStreamTest.cpp
folly/experimental/logging/test/XlogFile1.cpp
folly/experimental/logging/test/XlogTest.cpp
folly/experimental/logging/xlog.cpp
folly/experimental/logging/xlog.h