Improving SSHFS performance when reflecting changes in host directory

23,455

Solution 1

SSH is not designed to be a file transfer protocol. SSHFS works by periodically looking at the directory list and caching results.

You can control the caching behavior, but at the cost of performance as it relates to interactivity. If the SSH host you are connecting is accessed via a high latency link, or slow connection, then disabling caching is going to make things browsing the filesystem painful.

Anyway, see the man page, and experiement a bit.

man sshfs

   -o cache=YESNO
          enable caching {yes,no} (default: yes)

   -o cache_timeout=N
          sets timeout for caches in seconds (default: 20)

   -o cache_X_timeout=N
          sets timeout for {stat,dir,link} cache

Solution 2

Check that your host is in your /etc/hosts file, this solved the overhead for me

Source: http://hints.macworld.com/article.php?story=20050329185832952

Share:
23,455

Related videos on Youtube

chattsm
Author by

chattsm

Updated on September 18, 2022

Comments

  • chattsm
    chattsm over 1 year

    I have an SSHFS mount from a Ubuntu Server VM guest, mounting a host Mac OS X directory. Changes made directly in the Mac OS X host directory take approx 5 - 10 seconds to reflect in the Ubuntu Server VM guest mount.

    I am using the following command...

    sshfs user@host: ~/host

    What additional options (if any) will improve this latency?

    • Zoredache
      Zoredache about 12 years
      @Kyle, 5-10 seconds seems pretty close to the correct value since the default {stat,dir,link} cache is 20 seconds.
    • chattsm
      chattsm about 12 years
      @Kyle I'm simply running a watch -n 1 'ls -l ~/host' on the mount point and creating a directory or file in the host and seeing how long it takes to appear.
  • chattsm
    chattsm about 12 years
    Thanks, hadn't spent enough time reading the manual to see these options.
  • Jeff Burdges
    Jeff Burdges almost 12 years
    Any commands that'd force an immediate rescan? I suppose a shell script containing R=".rescan.tmp$RANDOM" if [ ! a $R ]; then touch $R; rm $R; fi perhaps? Any cleaner way?
  • Taipan
    Taipan about 6 years
    Shouldn't the OS cache DNS results? What if the IP changes?
  • OrangeDog
    OrangeDog about 3 years
    That appears to be because you were using an IP address with no hostname. If you just use a registered hostname directly you won't get the reverse lookup penalty.