Open chandlerc opened 2 years ago
Running env DYLD_PRINT_BINDINGS=1 watchman --version
is a good way to see just how much work Folly and Thrift in particular are causing here because of the huge number and size of C++ templates and such.
I told you I'd respond Monday, but then I got sick! Looking now. The macOS binaries we ship via GitHub Actions are statically-linked to folly and thrift. The Homebrew builds are community-maintained. It looks like the homebrew build doesn't explicitly request shared libraries, so I wonder what's going on. The only macOS machine I have is my work laptop, and we avoid Homebrew, so it's hard to test manually.
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:
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 likegit 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, thewatchman
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.