Repository navigation
Filesync performance improvements - #8818
Conversation
6a9bf60 to
89b2377
Compare
|
Need an upstream fix for some (potentially all?) of the remaining test failures: moby/buildkit#5521 |
fabf369 to
d2666a8
Compare
179b75a to
5f2ec52
Compare
This code was necessary in early iterations of modules that had function caching enabled universally. However, currently we only enable function caching for some internal SDK function calls. Those are limited enough that I believe the blob linking is not necessary. They have inputs that are sourced from filesyncs, but because those are inputs you won't end up in a situation where you get a cached result from an SDK that refers to filesync cache refs that weren't loaded. We will need something along these lines again when we enable general function call caching, but it will have to look a little different since filesync blobs no longer go through the content store (which is good since it avoids performance overhead). Signed-off-by: Erik Sipsma <[email protected]>
The hashing of stats via creating tar headers was a surprisingly large source of allocations+memory and also unnecessary. The new implemention elminates ~1m allocations over the course of syncing the full linux src code repo (test case I'm using) and the engine's memory usage is noticeable lower+more stable watching htop. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
The verification that concurrent syncs of conflicting data before this was too coarse and led to errors when unrelated changes were made to completely different parts of the local filesystem. Now the verification is fine grain and should only error when conflicts arise for specific paths. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
|
Pushed the fix for case-insensitive filesystems cfae16d Basically just wrote a version of @helderco I was able to repro that error on my macbook and confirmed it's fixed, so gonna merge now but appreciate a double-check on your end that it's all gone for you to whenever you have a min. |
Yeah, I can confirm it works for me now 🚀 |
Goals
Primary:
Secondary:
Performance Improvements
I used the git repo for the Linux kernel as a stress-test case since it contains multiple GB of source files.
The main improvements are around filesyncs of already loaded data and parallel syncs, but there's some meaningful improvement to uncached syncs too for huge filesync cases.
The improvements in cache re-use and parallel syncs are expected to be most applicable to module loading and contextual directory argument usage.
Uncached load of full repo except
.git(.host | directory . --exclude .git | entries)Subsequent load of
drivers/subdir (.host | directory drivers | entries)drivers/subdir was already loaded in the previous sync so there shouldn't be any loading of new data. The old implementation didn't handle this, but the new one does. You can see in the traces that the majority of the time in the new implementation is spent copying files/dirs (in order to make an immutable cache entry); this is also possible to improve in the future too.Cached load of full repo except
.gitusing include instead of exclude (.host | directory . --include **,!.git | entries)Re-run full repo load from separate parallel session (
.host | directory . --exclude .git | entries)Implementation Details
Biggest problems with previous implementation:
blobAPI and went through the content store for simplicity. Going through the content store involves a ton of overhead and extra copying though. It also created more situations in which the local cache sync ref was locked and would thus result in more mysterious uncached syncs.contenthashlib from upstream to calculate and store content hash metadata rather than going through the content store. It also re-uses existing equivalent refs whenever possible.There's a ton of other little optimizations in various places (noted most of them with comments in the code).
Future improvements and features
withExeclayers complicate cache re-use quite a bit (you can end up with different filesystems that have the same stable client ID)drivers/subdir added ~5s of overhead, to give an idea of how much of a difference this might be able to make (not enough to be worth it here, but possibly worth it someday)dagger shelluse cases