CMake option to enable statically linking some of the libraries used
- Dominant language
- C++
- Stars
- 13.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
On macOS it seems like some of the libraries used by Watchman result in the binary being very slow to start. On my x86 MBP with the Homebrew installed binary:
```
Benchmark 1: watchman --version
Time (mean ± σ): 108.4 ms ± 6.4 ms [User: 83.1 ms, System: 7.9 ms]
Range (min … max): 98.7 ms … 123.5 ms 20 runs
```
I can reproduce this by building myself, so I don't think it has anything to do with Homebrew.
I profiled it, and it looks like its spending most of its time loading shared libraries -- likely hitting lots of page faults and having to do a lot of complex symbol resolution due to the large number and complex structure of C++ template symbols. Folly, and Thrift libraries have many thousands of symbols exported. =[
Honestly, even 100ms is pretty fast and for most applications would be completely fine. However, because a common use case for running the `watchman` command is to optimize the latency of commands like `git status` w/o touching the filesystem, it seems really unfortunate for the binary to require ... well ... touching the filesystem a lot. And with the current overhead, 2 invocations adds up to a quarter second of latency pretty quickly. Fundamentally, the `watchman` binary is often used in an extremely latency sensitive setting per-execution, and likely needs some unusual steps to make that work well on non-Linux platforms.
It would be great to have a CMake option to link a bunch of the heavy-weight C++ libraries statically into the binary so that its startup could be a bit lower latency. I tried a few experiments to achieve this and wasn't successful sadly.
Contributor guide
Assessment
This issue has not been assessed yet.