sapling/eden/fs/utils
Victor Zverovich 3285a8f909 Replace Folly Format with fmt in logger to reduce binary size
Summary:
Now that fmt is available in Folly builds (D14813810), use it to reduce binary code size in Folly Logger. This is done by moving most of the formatting logic behind the type-erased `vformat` API. Previously it was instantiated for all combinations of formatting argument types used in calls to `FB_LOGF` and `XLOGF` in a program.

The effect of this change can be illustrated by looking at symbol sizes as given by `nm -S -td` for the following test function:

```
void test_log() {
  FB_LOGF(logger, WARN, "num events: {:06d}, duration: {:6.3f}", 1234, 5.6789);
}
```
compiled in `opt` mode.

`nm` before:

```
0000000004236736 0000000000000231 T test_log()
0000000004236992 0000000000001002 W std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > folly::LogStreamProcessor::formatLogString<int, double>(folly::Range<char const*>, int const&, double const&)
```

`nm` after:

```
0000000004237536 0000000000000231 T test_log()
0000000004237792 0000000000000251 W std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > folly::LogStreamProcessor::formatLogString<int, double>(folly::Range<char const*>, int const&, double const&)
0000000004238048 0000000000000740 W folly::LogStreamProcessor::vformatLogString[abi:cxx11](folly::Range<char const*>, fmt::v5::format_args, bool&)
```

Before we had one 1002 byte instantiation of `formatLogString<int, double>`. With this change it was reduced 4x to 251 bytes and non-template function `vformatLogString` was added which is shared among all logging calls. The size of `test_log` remained unchanged. There are even bigger savings from Folly Formatter instantiations which are no longer needed, e.g.

```
0000000004238032 0000000000001363 W _ZNK5folly13BaseFormatterINS_9FormatterILb0EJRKiRKdEEELb0EJS3_S5_EEclIZNKS7_8appendToINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEENSt9enable_ifIXsr12IsSomeStringIT_EE5valueEvE4typeERSH_EUlNS_5RangeIPKcEEE_EEvSK_
```

So in total this change results in ~5x per-call/instantiation binary size. It is possible to reduce binary size even further but it is not done in the current diff to keep it manageable.

In addition to binary size improvements, switching to fmt will potentially

* allow catching errors in format strings at compile time,
* simplify future migration to C++20 [`std::format`](http://eel.is/c++draft/format).

Reviewed By: simpkins

Differential Revision: D15485589

fbshipit-source-id: 06db4436839f11c2c3dbed7b36658e2193343411
2019-11-18 05:53:08 -08:00
..
test add memory usage statistics to macOS 2019-10-28 11:19:44 -07:00
BucketedLog.h Tidy up license headers 2019-10-11 05:28:23 -07:00
Bug.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
Bug.h Tidy up license headers 2019-10-11 05:28:23 -07:00
ChronoParse.cpp Replace Folly Format with fmt in logger to reduce binary size 2019-11-18 05:53:08 -08:00
ChronoParse.h Tidy up license headers 2019-10-11 05:28:23 -07:00
ChronoUnit.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
ChronoUnit.gperf update license header in remaining files 2019-06-19 17:02:46 -07:00
ChronoUnit.h Tidy up license headers 2019-10-11 05:28:23 -07:00
Clock.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
Clock.h Tidy up license headers 2019-10-11 05:28:23 -07:00
CMakeLists.txt eden: remove legacy bind mount code 2019-09-30 18:57:14 -07:00
CoverageSet.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
CoverageSet.h Tidy up license headers 2019-10-11 05:28:23 -07:00
DirType.h Tidy up license headers 2019-10-11 05:28:23 -07:00
FaultInjector.cpp build deprecation-clean 2019-11-12 16:31:54 -08:00
FaultInjector.h Tidy up license headers 2019-10-11 05:28:23 -07:00
FutureSubprocess.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
FutureSubprocess.h Tidy up license headers 2019-10-11 05:28:23 -07:00
FutureUnixSocket.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
FutureUnixSocket.h Tidy up license headers 2019-10-11 05:28:23 -07:00
IDGen.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
IDGen.h Tidy up license headers 2019-10-11 05:28:23 -07:00
IoFuture.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
IoFuture.h Tidy up license headers 2019-10-11 05:28:23 -07:00
LazyInitialize.h Tidy up license headers 2019-10-11 05:28:23 -07:00
LeaseCache.h Tidy up license headers 2019-10-11 05:28:23 -07:00
MappedDiskVector.h Tidy up license headers 2019-10-11 05:28:23 -07:00
Memory.h Tidy up license headers 2019-10-11 05:28:23 -07:00
PathFuncs.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
PathFuncs.h Replace Folly Format with fmt in logger to reduce binary size 2019-11-18 05:53:08 -08:00
PathMap.h Tidy up license headers 2019-10-11 05:28:23 -07:00
ProcessAccessLog.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
ProcessAccessLog.h Tidy up license headers 2019-10-11 05:28:23 -07:00
ProcessNameCache.cpp clang-format 2019-10-24 14:56:43 -07:00
ProcessNameCache.h Tidy up license headers 2019-10-11 05:28:23 -07:00
ProcUtil.cpp Replace Folly Format with fmt in logger to reduce binary size 2019-11-18 05:53:08 -08:00
ProcUtil.h add memory usage statistics to macOS 2019-10-28 11:19:44 -07:00
ServiceAddress.cpp eden: fix API server failures due to service router disabled sliently 2019-10-22 15:06:47 -07:00
ServiceAddress.h Tidy up license headers 2019-10-11 05:28:23 -07:00
SortedInsert.h Tidy up license headers 2019-10-11 05:28:23 -07:00
SSLContext.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
SSLContext.h Tidy up license headers 2019-10-11 05:28:23 -07:00
StatTimes.h Tidy up license headers 2019-10-11 05:28:23 -07:00
Synchronized.h Tidy up license headers 2019-10-11 05:28:23 -07:00
SystemError.h Tidy up license headers 2019-10-11 05:28:23 -07:00
TimeUtil.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
TimeUtil.h Tidy up license headers 2019-10-11 05:28:23 -07:00
UnboundedQueueExecutor.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
UnboundedQueueExecutor.h Tidy up license headers 2019-10-11 05:28:23 -07:00
UnixSocket.cpp warn on unused exception parameter 2019-10-28 17:49:23 -07:00
UnixSocket.h Tidy up license headers 2019-10-11 05:28:23 -07:00
XAttr.cpp Tidy up license headers 2019-10-11 05:28:23 -07:00
XAttr.h Tidy up license headers 2019-10-11 05:28:23 -07:00