Repository navigation
less fsyncs via overlay volatile - #11559
Conversation
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
ffa4bc7 to
58b2487
Compare
| return fmt.Errorf("mount rootfs: %w", err) | ||
| } | ||
|
|
||
| overlayIncompatDirs := overlay.VolatileIncompatDirs(rootMnts) |
There was a problem hiding this comment.
For the curious (as I was) what an 'incompat' dir is: https://docs.kernel.org/filesystems/overlayfs.html#volatile-mount
Seems like a way to determine whether a mount should be discarded in the event of a rough shutdown. I guess it shouldn't matter much in our case, but that the right thing to do is to clean it up after use in the 'happy path'? The docs also say the "user" should notice its presence and discard the dirs, so I guess the OS doesn't do that itself?
There was a problem hiding this comment.
Yeah exactly, sorry I explained all this in more depth in the updated commit message but that doesn't autopropagate to the PR description. I'll put a nice comment on the code before merging too
Looked into the chown perf regression with ebpf and found that each chown was causing overlay to call fsync on every file (within its copy-up internal functions), each of which took ~8ms on my laptop. 8ms isn't a lot to a human but when you are serially chowning 100k files it adds up quickly. Syscalls like this shouldn't be that slow generally, especially for the test case where each file is only 1 byte. It's not entirely clear to me why overlay makes this so slow. I can repro the slowness outside of dagger with hand-crafted overlay mounts, but when I remove overlay from the equation and use the same underlying filesystem it's much much faster. This all reminded me of marcosnils's effort a long time ago to upstream support for the overlay volatile option, which met a bunch of friction and didn't get merged. Thankfully, we no longer have those problems! `volatile` skips the fsyncs overlay does and fixes the perf problem for me. There's a good chunk of trickiness and careful handling needed here since we sometimes need to remount overlays that were previously mounted with the same upper/work dirs (cache mounts, exec-after-failure mounts, etc.), in which case the leftover `<workdir>/work/incompat` dir needs to be removed to prevent overlay from error'ing out (its attempt to warn us that the mount may have been corrupted after a previous crash). Signed-off-by: Erik Sipsma <[email protected]>

Looked into the chown perf regression with ebpf and found that each chown was causing overlay to call fsync on every file (within its copy-up internal functions), each of which took ~8ms on my laptop. 8ms isn't a lot to a human but when you are serially chowning 100k files it adds up quickly. Syscalls like this shouldn't be that slow generally, especially for the test case where each file is only 1 byte.
It's not entirely clear to me why overlay makes this so slow. I can repro the slowness outside of dagger with hand-crafted overlay mounts, but when I remove overlay from the equation and use the same underlying filesystem it's much much faster.
This all reminded me of @marcosnils's effort a long time ago to upstream support for the overlay
volatileoption, which met a bunch of friction and didn't get merged. Thankfully, we no longer have those problems!volatileskips the fsyncs overlay does and fixes the perf problem for me.cc @grouville
First run in CI is definitely quite fast, a couple of checks are several minutes faster than they were most recently on main: