Cache local mounts for filesystem access APIs by jedevc · Pull Request #6387 · moby/buildkit (original) (raw)

@jedevc jedevc changed the titleCache mounts over session Cache local mounts for filesystem access APIs

Nov 28, 2025

jsternberg

tonistiigi

@jedevc

In addition to being wasteful, without this, concurrent calls to Mount would have lost the previous target and so would never have been removed.

Signed-off-by: Justin Chadwell me@jedevc.com

@jedevc

Previously, each call to ReadFile/ReadDir/StatFile would trigger an entire Mount+Unmount operation. This could result in terrible performance for repeated filesystem accesses - potentially worse that one Mount+Unmount per file, if the file is read in ranges.

To resolve this, we now directly store the localMounter in the gateway, and rely on the fact that repeated calls to it return the same value. These mounts will only be removed when the gateway itself is released.

Signed-off-by: Justin Chadwell me@jedevc.com

@jedevc

Signed-off-by: Justin Chadwell me@jedevc.com

tonistiigi

@jedevc jedevc deleted the cache-mounts-over-session branch

January 6, 2026 09:59

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

[ Show hidden characters]({{ revealButtonHref }})