Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds a couple of tunable, which I found useful in our buildbarn setup.
We have 10 bare metal hosts managed by k8s. Each host has two 8TiB NVME SSD linked in software mirror raid. These SSDs support write speed of about 2.5Gb/s. We deploy buildbarn with memory limit set to 64Gi (rest is used for CI) and locate 1TiB of disk space for it, sharded over 10 files.
I think it always make sense to call fallocate, when creating the /blocks file. ext4 filesystem on linux default to lazy allocation, and if we create 100Tb file, by default 0 blocks are allocated upfront. Instead, allocation code is running during Pwrite, or even during writeback. Causing all sort of problems with fragmentation and lock contention inside the kernel.
I do not think mmap is always useful for file read, when file does not fit into memory (which is our case). Pread should give more predictable performance, since OS sees full range of requested data in a single syscall. Instead of second guessing how much data it needs to prefetch from the page-fault pattern.
It makes sense to sync data to disk after Pwrite. NVME is fast enough, so there is no degradation in performance. But disk write is issued synchronously from buildbarn thread. Without this, dirty pages are piled up in memory, and write to disk is started at random point in time in the future, when process tries allocating new memory, hits container memory limit and starts kernel memory reclaim.
With all three options applied I was able to get full underlying NVME write speed in synthetic benchmarks with consistent timings.
Without these options, buildbarn died under our CI load, when we tries switching to buildbarn from our current bazel-remote setup.
I did not have enough time to do a clear before/after experiment in our CI setup, but all my experience of working with storages tells me that these changes are worthwhile.