Improve Git monorepo performance with a file system monitor
Blog post from GitHub
Git's FSMonitor feature, introduced in version 2.37.0, significantly enhances the performance of Git commands like `git status` in large monorepos by reducing the need for extensive worktree searches. FSMonitor operates as a long-running daemon that receives file system change notifications, allowing it to efficiently track modified files and directories in real-time. This reduces the fixed cost of repeated searches, as it uses tokens to group changes, ensuring subsequent commands focus only on altered files. By integrating FSMonitor with the core.untrackedcache, Git optimizes the search for untracked files, offering a substantial speed boost by avoiding redundant checks. FSMonitor is easy to enable with a simple configuration change and is available on macOS and Windows. Complementing FSMonitor, the sparse checkout feature allows users to exclude unnecessary files from their worktree, further enhancing performance. Additionally, Git's compatibility with external tools like Watchman means that users can choose between built-in and third-party monitoring solutions to suit their specific requirements, making large repositories more manageable and efficient.