X Tutup
Skip to content

Flags for specifying bind mount consistency#31047

Merged
thaJeztah merged 1 commit intomoby:masterfrom
yallop:cli-v-state
Mar 13, 2017
Merged

Flags for specifying bind mount consistency#31047
thaJeztah merged 1 commit intomoby:masterfrom
yallop:cli-v-state

Conversation

@yallop
Copy link
Contributor

@yallop yallop commented Feb 15, 2017

This PR introduces a small change to the Docker CLI as part of a larger project to address some longstanding file sharing performance on Docker for Mac ([1], [2]).

The poor performance of bind mounts in Docker for Mac for some applications arises from osxfs ensuring perfectly consistent views of bind mounts between container and host: reads, writes and events from within a container are propagated synchronously to the host, and vice versa.

Perfect consistency is the right default, but for some workloads where it's unnecessary it puts a low ceiling on performance. To improve performance for such workloads, we plan to allow the user to relax consistency guarantees for individual bind-mounted directories.

The full details of the proposal are available here. This patch includes one small piece of the work, namely additional bind options cached, delegated, consistent, for selecting consistency modes. Although the immediate aim is improving osxfs performance, these options are not macOS-specific; they give a general view of consistency that applies to many systems, both for bind mounts and volume plugins. For example,

  • essentially the same consistency taxonomy is used by Infinit
  • the same approach may be used in future to improve performance on Windows
  • on systems that directly expose the host file system to a container, such as Linux, ignoring the options is an acceptable implementation of all three modes. (Even on Linux a container runtime could in principle take advantage of the relaxed semantics associated with delegated and cached.)

@AkihiroSuda
Copy link
Member

Can we add these flags to --mount (opts/mount.go) as well?

@yallop
Copy link
Contributor Author

yallop commented Feb 16, 2017

@AkihiroSuda: a1649ef

@dnephin
Copy link
Member

dnephin commented Feb 16, 2017

Design LGTM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if State is the right term here.

Would something like Consistency work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, State is a bit general. Consistency sounds good.

Copy link
Member

@dnephin dnephin Feb 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump, now that this PR is in code review

@cpuguy83
Copy link
Member

While I definitely appreciate the goal of making osxfs faster (directly affects me!) this does not seem right.
This is adding an API only change and nothing in Docker would even be using it.

Additionally it seems like we're pushing osxfs performance issues to the user to deal with.
Suddenly we'll see compose files everywhere with cached or delegated added to them just so performance doesn't suck on OSX.

@yallop
Copy link
Contributor Author

yallop commented Feb 17, 2017

Additionally it seems like we're pushing osxfs performance issues to the user to deal with.

Improving performance on Docker for Mac is an immediate goal of this introducing this feature now, but there's nothing specific to osxfs in the design.

We're allowing the user to describe the consistency requirements of the mount, because that's information that only the user has, and because Docker can make use of that information to improve performance.

The interface currently has no way to enable caching because it's been designed with the Linux implementation in mind. If we want Docker to perform well on other systems then we need to adapt the interface so that it's less Linux-specific.

Suddenly we'll see compose files everywhere with cached or delegated added to them just so performance doesn't suck on OSX.

We can certainly hope that people start to use the feature. If we see cached or delegated in compose files it's because those are the consistency levels required by the application.

@yallop
Copy link
Contributor Author

yallop commented Feb 20, 2017

@dnephin, did the label (rebuild/experimental) trigger an experimental rebuild? I'm not sure whether the test failure represents a genuine problem.

@justincormack
Copy link
Contributor

I just retriggered the experimental rebuild, we were having some issues, I don't think it was triggered as the label was not automatically removed.

@yallop
Copy link
Contributor Author

yallop commented Feb 22, 2017

There's not a lot of activity on this issue, perhaps because it's not clear to the casual reader how critical this patch is to the success of Docker on macOS.

Here's an account posted on Reddit yesterday of how one company gave up on Docker:

This is our primary blocker for not using docker in our infrastructure right now. [...]
Docker is basically a no go at our company because of this issue. (Entire office uses MBP's)
There are some workarounds using rsync or something but it just seems like too much complexity.
I actually ended up spending a ton of time dockerizing our stack only to run into this brick wall. It was devistating.

This PR allows us to address the company's major concern. And this is far from an isolated case; it would be easy to give many more such examples.

@cpuguy83
Copy link
Member

@yallop I get it, I really do... but again this is not doing anything but changing the API. Docker is not consuming it any way. Major red flag here.

Why not at least provide a switch to change the default behavior in d4mac preferences? This could be done either globally or per share.
If there's still an issue after such an option is available it can be addressed accordingly.

@nathanleclaire
Copy link
Contributor

I applaud the general effort to improve shared folder performance in Docker for Mac but I share @cpuguy83's concerns that this is adding something to the Docker API which does not get used by the Docker daemon at all.

Why would this not be added as a configurable setting in Docker for Mac? It seems to be very Docker for Mac specific. The Docker daemon is designed to run on Linux and Windows, but this adds a parameter which will be ignored by both.

@dsheets
Copy link
Contributor

dsheets commented Feb 23, 2017

@nathanleclaire while Docker for Mac is the first use case for these semantics, they are applicable to Infinit, Docker for Windows, volume plugins, and potentially Docker on Linux with a future extension point (delegated can effectively disable disk flushes during container run-time).

Copy link
Member

@cpuguy83 cpuguy83 Feb 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full, or synchronous ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

synchronous seem to refer more to the mechanism used to accomplish the consistency.

Where as consistent refers to the desired "state".

I prefer consistent here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change State here to Consistency

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or ConsistencyLevel ?

@cpuguy83
Copy link
Member

Just for the record, I was wooed and am ok with this change.

@dsheets
Copy link
Contributor

dsheets commented Feb 24, 2017

@cpuguy83 we're open to changing the name of the field and the names of the modes. We initially selected state and [consistent,cached,delegated,default] by evaluating three criteria:

  1. -v comprehensibility
  2. --mount comprehensibility
  3. verbalization

The cases considered look like:

-v /a:/a:consistent pronounced "the mount is consistent"
-v /a:/a:cached pronounced "the mount is cached"
-v /a:/a:delegated pronounced "the mount is delegated"
--mount type=bind,src=/a,dst=/a,state=consistent pronounced "the mount's state is consistent"
--mount type=bind,src=/a,dst=/a,state=default pronounced "the mount's state is default"
--mount type=bind,src=/a,dst=/a,state=cached pronounced "the mount's state is cached"
--mount type=bind,src=/a,dst=/a,state=delegated pronounced "the mount's state is delegated"

I think you are proposing to change consistent to synchronous or full and state to consistency? I understand that state seems somewhat ambiguous about whether it is referring to the state of the mount concept or the underlying file system. I think it is unlikely to collide with future changes that do not interact with this specification as state is too general for any Docker mount concept and only makes sense in reference to the state of the file system itself.

I don't think full will work due to the case -v /a:/a:full which is not explanatory.

-v /a:/a:synchronous makes more sense but is longer, contains non-phonetic letters, and describes the implementation rather than the user's obervable experience. We are fine with naming the mode this if these trade-offs are considered and deemed acceptable. sync wouldn't have as many of these downsides but still describes implementation rather than behavior.

Renaming state to consistency would result in:

--mount type=bind,src=/a,dst=/a,consistency=consistent pronounced "the mount's consistency is consistent"
--mount type=bind,src=/a,dst=/a,consistency=default pronounced "the mount's consistency is default"
--mount type=bind,src=/a,dst=/a,consistency=cached pronounced "the mount's consistency is cached"
--mount type=bind,src=/a,dst=/a,consistency=delegated pronounced "the mount's consistency is delegated"

consistency is significantly longer than state, though arguably more descriptive. I don't think the verbalizations read as smoothly as state but they are still understandable.

We also believe that the terms used should be the same between -v and --mount and any future uses. In discussion with Ian Campbell, he suggested that state is ambiguous with some existing flags like ro which was undesirable. I know that the design of ro and rw are themselves in question as they are anonymous booleans. I think it could make sense to unify them with the state field to produce arguments like

--mount type=bind,src=/a,dst=/a,state=cached+ro pronounced "the mount's state is cached and read-only"

Ultimately, this all comes down to various comprehensibility and ease-of-use trade-offs in the design space. We think that the current names are the best of those we considered during design (e.g. state was initially semantics!) but we're happy to explore other options in a framework that takes the whole UX into account.

What issues do you foresee with the current set of names?

@dnephin
Copy link
Member

dnephin commented Feb 24, 2017

I think state is too generic. consistency makes the setting more clear.

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the API types here rather than redefining the strings?

Copy link
Contributor Author

@yallop yallop Mar 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpuguy83: good idea. See e02de44.

@cpuguy83
Copy link
Member

cpuguy83 commented Mar 1, 2017

14:29:39 These files are not properly gofmt'd:
14:29:39  - api/types/mount/mount.go
14:29:39 
14:29:39 Please reformat the above files using "gofmt -s -w" and commit the result.

Also needs a squash.

@yallop
Copy link
Contributor Author

yallop commented Mar 10, 2017

I've opened a separate in-progress PR for documentation, following @justincormack's suggestion, so as not to delay the merge here: #31749.

@justincormack
Copy link
Contributor

justincormack commented Mar 11, 2017 via email

@yallop
Copy link
Contributor Author

yallop commented Mar 11, 2017

I've pushed docs to #31749.

@thaJeztah
Copy link
Member

Thanks for doing the docs PR; let's go ahead and merge this

@thaJeztah thaJeztah merged commit 7f6e708 into moby:master Mar 13, 2017
@GordonTheTurtle GordonTheTurtle added this to the 17.04.0 milestone Mar 13, 2017
@yallop yallop deleted the cli-v-state branch March 13, 2017 11:01
@mdlinville
Copy link
Contributor

This seems to be missing CLI docs. @thaJeztah PTAL

@thaJeztah
Copy link
Member

@mstanleyjones see #31749

@mdlinville
Copy link
Contributor

Wow! Thanks.

vdemeester added a commit that referenced this pull request Mar 22, 2017
Add documentation for bind mount consistency flags (#31047).
thaJeztah pushed a commit to thaJeztah/docker that referenced this pull request Apr 3, 2017
Add documentation for bind mount consistency flags (moby#31047).
(cherry picked from commit 9439402)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@dsheets dsheets mentioned this pull request May 5, 2017
@zikphil
Copy link

zikphil commented Jun 8, 2017

Just wanted to thank the Moby team for integrating those changes. 👍

Source string `json:",omitempty"`
Target string `json:",omitempty"`
ReadOnly bool `json:",omitempty"`
Consistency Consistency `json:",omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this didn't land on BindOptions? This seems to only apply to bind mounts.

briancain pushed a commit to briancain/vagrant that referenced this pull request Jul 27, 2018
Adds the `docker_consistency` option, which sets the Docker volume
consistency level. This can be used to greatly improved synced folder
performance, especially on macOS.

See for details: moby/moby#31047
briancain pushed a commit to briancain/vagrant that referenced this pull request Jul 27, 2018
Adds the `docker_consistency` option, which sets the Docker volume
consistency level. This can be used to greatly improved synced folder
performance, especially on macOS.

See for details: moby/moby#31047
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

X Tutup