Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable auto cache and disable compression on sshfs mounts #1605

Conversation

jasonmccallister
Copy link
Contributor

@jasonmccallister jasonmccallister commented Jun 17, 2020

This is related to #1502

sshfs has a default cache duration of 20 seconds. Since multipass is a local virtual machine, it might make sense to disable compression (as we are less worried about the network traffic) and auto caching enables caching based on modification times.

Note: this came out of research and trial and error based on this SE post: https://superuser.com/a/1359783/215387

Happy to discuss the options in further detail, but the default 20 second cache is rather noticeable in our project.

Signed-off-by: Jason McCallister <jason@craftcms.com>
@Saviq
Copy link
Collaborator

Saviq commented Jun 23, 2020

Hi @jasonmccallister, thanks for this!

You will need to update the tests:

[  FAILED  ] 3 tests, listed below:
[  FAILED  ] SshfsMountSuccess/SshfsMountExecute.test_succesful_invocation/0, where GetParam() = ("target", { ("sudo env LD_LIBRARY_PATH=/foo/bar /baz/bin/sshfs -V", "FUSE library version: 2.9.0\n"), ("sudo env LD_LIBRARY_PATH=/foo/bar /baz/bin/sshfs -o slave -o transform_symlinks -o allow_other -o nonempty :\"source\" \"/home/ubuntu/target\"", "don't care\n") })
[  FAILED  ] SshfsMountSuccess/SshfsMountExecute.test_succesful_invocation/1, where GetParam() = ("target", { ("sudo env LD_LIBRARY_PATH=/foo/bar /baz/bin/sshfs -V", "FUSE library version: 3.0.0\n"), ("sudo env LD_LIBRARY_PATH=/foo/bar /baz/bin/sshfs -o slave -o transform_symlinks -o allow_other :\"source\" \"/home/ubuntu/target\"", "don't care\n") })
[  FAILED  ] SshfsMountSuccess/SshfsMountExecute.test_succesful_invocation/2, where GetParam() = ("target", { ("sudo env LD_LIBRARY_PATH=/foo/bar /baz/bin/sshfs -V", "weird fuse version\n"), ("sudo env LD_LIBRARY_PATH=/foo/bar /baz/bin/sshfs -o slave -o transform_symlinks -o allow_other :\"source\" \"/home/ubuntu/target\"", "don't care\n") })
 3 FAILED TESTS

@Saviq Saviq requested a review from townsend2010 July 6, 2020 14:12
Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

I'm +1 with this. I don't see any regressions and looks like it should work on older versions of sshfs & fuse if users' instances has that. All we need is the 3 tests to be fixed and it's good to go.

@jasonmccallister
Copy link
Contributor Author

Thank you! I’ll update these tests tomorrow, apologies for the delay!

@townsend2010
Copy link
Contributor

Still have a failing test:

[  FAILED  ] 1 test, listed below:
[  FAILED  ] SshfsMountSuccess/SshfsMountExecute.test_succesful_invocation/0, where GetParam() = ("target", { ("sudo env LD_LIBRARY_PATH=/foo/bar /baz/bin/sshfs -V", "FUSE library version: 2.9.0\n"), ("sudo env LD_LIBRARY_PATH=/foo/bar /baz/bin/sshfs -o slave -o transform_symlinks -o allow_other -o auto_cache -o Compression=no :\"source\" \"/home/ubuntu/target\"", "don't care\n") })
 1 FAILED TEST

@jasonmccallister
Copy link
Contributor Author

@townsend2010 I just pushed another commit. Unfortunately I can't compile this locally on macOS, so I need to use Travis :)

@townsend2010
Copy link
Contributor

Ugh, now clang-format is complaining and won't start the build- https://travis-ci.org/github/canonical/multipass/jobs/705843563

As an aside, it's possible to build Multipass inside a Multipass instance, just allocate enough CPU's and memory and it builds just fine.

@Saviq
Copy link
Collaborator

Saviq commented Jul 7, 2020

Ugh, now clang-format is complaining and won't start the build- https://travis-ci.org/github/canonical/multipass/jobs/705843563

Fixed that :)

@codecov
Copy link

codecov bot commented Jul 8, 2020

Codecov Report

Merging #1605 into master will increase coverage by 1.66%.
The diff coverage is 78.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1605      +/-   ##
==========================================
+ Coverage   73.79%   75.45%   +1.66%     
==========================================
  Files         223      223              
  Lines        8163     8263     +100     
==========================================
+ Hits         6024     6235     +211     
+ Misses       2139     2028     -111     
Impacted Files Coverage Δ
include/multipass/process/basic_process.h 100.00% <ø> (ø)
include/multipass/process/process.h 100.00% <ø> (ø)
include/multipass/process/process_spec.h 100.00% <ø> (ø)
include/multipass/process/qemuimg_process_spec.h 100.00% <ø> (ø)
include/multipass/sshfs_mount/sshfs_mounts.h 100.00% <ø> (ø)
include/multipass/utils.h 61.53% <ø> (ø)
include/multipass/virtual_machine_factory.h 100.00% <ø> (ø)
src/cert/ssl_cert_provider.cpp 87.23% <ø> (ø)
src/client/cli/client.cpp 100.00% <ø> (ø)
src/client/cli/cmd/common_cli.cpp 72.13% <ø> (ø)
... and 60 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0688f9...c8466d8. Read the comment docs.

@jasonmccallister
Copy link
Contributor Author

jasonmccallister commented Jul 8, 2020

Thank you for stepping in and resolving those issues @Saviq!

Is there a way to test a macOS build with this change?

Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

Ok, I'm good with this.

@Saviq
Copy link
Collaborator

Saviq commented Jul 9, 2020

bors try

bors bot added a commit that referenced this pull request Jul 9, 2020
@Saviq
Copy link
Collaborator

Saviq commented Jul 9, 2020

@jasonmccallister the macOS package got built here: e84fa46#comments

@bors
Copy link
Contributor

bors bot commented Jul 9, 2020

try

Build succeeded:

@jasonmccallister
Copy link
Contributor Author

Thanks @Saviq giving it a try now. If there are existing mounts, do they need to be readded or will updating multipass and restarting the machine suffice?

@townsend2010
Copy link
Contributor

Hi @jasonmccallister,

Updating Multipass and restarting the instance is fine.

@townsend2010
Copy link
Contributor

Hi @jasonmccallister,

Have you had a chance to try it out and if so, does this work better for your project?

Thanks!

@jasonmccallister
Copy link
Contributor Author

@townsend2010 its better - still not perfect but results seem favorable in my testing - will talk to the team and get some additional feedback.

@jasonmccallister
Copy link
Contributor Author

@townsend2010 there is a minor improvement on the speeds - but we are still seeing issues. What would be the performance impact in disabling the cache altogether? I think it may cause more harm than good, but it might resolve our issues.

Another idea we are considering is embedded a "watcher" in the virtual machine that will scan the directories for our needs. That seems to "force" sshfs to update its cache instantly. We do have some large files (PHP and Node dependency directories) that the watcher can ignore but wanted to get some thoughts for your team?

@townsend2010
Copy link
Contributor

Hey @jasonmccallister,

I did some basic testing of disabling the cache via -o dir_cache=no (which replaces -o cache=no in older sshsf versions) and I see a ~15% decrease in read speeds. I think the better short term answer is to introduce a setting that globally sets the caching policy for all Multipass mounts. I will look into doing that soon.

@jasonmccallister
Copy link
Contributor Author

That makes sense, no caching I'm sure would have some impacts. What about setting the cache duration to 3 seconds?

@townsend2010
Copy link
Contributor

Hi @jasonmccallister,

I set the cache duration to 3 seconds and saw an ~4% decrease in read speeds which to me is acceptable. I will put up a PR with this change and after the packages build, I'd like to ask you test to see if this improves things for you.

Thanks!

@townsend2010
Copy link
Contributor

Hi @jasonmccallister,

Both the Linux and Mac versions of my PR are available at #1654 (comment). Please let me know in that PR how it goes for you. Thanks!

@jasonmccallister
Copy link
Contributor Author

@townsend2010 I will give it a try right now. Thank you!

@jasonmccallister
Copy link
Contributor Author

@townsend2010 that is a huge improvement on my side, I will ask a few other team members to test and verify but that looks like it was the right combo! Thank you!

@townsend2010
Copy link
Contributor

@jasonmccallister,

That is awesome! To make sure I'm not missing something on performance under "normal" (whatever "normal" is 😄) conditions, I'll get some of my teammates to try out my PR as well. Thanks again!

@jasonmccallister
Copy link
Contributor Author

@townsend2010 feedback I've received from the community has been really positive with this change. Thank you!

@Saviq Saviq added this to the v1.4.0 milestone Jul 27, 2020
@Saviq
Copy link
Collaborator

Saviq commented Aug 7, 2020

We're merging #1654 instead :)

@Saviq Saviq closed this Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants