1

I have set up a mount point using the s3fs FUSE filesystem and autofs to talk to an Amazon S3 bucket, but it is excruciatingly slow to edit a file in the bucket in emacs - it is basically unusable due to the delays after every keypress, which cause emacs to hang completely until it finishes its I/O.

What can I do to avoid this problem?

2 Answers 2

1

This appears to have been due to this issue in projectile, which I use.

I followed the suggestion in a comment on that issue of using this workaround:

(add-hook 'find-file-hook
          (lambda ()
            (if (locate-dominating-file default-directory ".git")
                (projectile-mode))))

i.e. removing

(global-projectile-mode)

from my .emacs and replacing it with the above code, and performance is now acceptable (there is a lag on opening the file, and on the first keypress that makes an edit to the file, as I would expect). This does mean that projectile is only activated in git projects, but that's fine for me - and the same workaround can easily be extended to other version control systems if necessary.

0

I initially used this simple Linux script to copy the file to a fast filesystem and then copy it back again (see my other answer for what I am now doing). Only the line beginning with TMP= should need to be changed for other operating systems. The only slight complexity is dealing with simultaneous edits to identically-named files in different S3 buckets (without replacing the filename with randomly-generated garbage, which would be the easy way out).

#! /bin/bash -peux
# Edit files from slow filesystems in emacs
TMP=/run/user/$(id -u)
dest=$TMP/"$(basename "$1")"
src_dir="$(dirname "$1")"
prefix=""
while [ -e "$dest" ]; do
    prefix="$(basename "$src_dir")/$prefix"
    src_dir="$(dirname "$src_dir")"
    if [ "$src_dir" = "/" ]; then
        echo Unable to generate unique filename >&2
        exit 2
    fi
    mkdir $TMP/"$prefix" || :
    dest=$TMP/"$prefix$(basename "$1")"
done
cp -p "$1" $dest || :
emacsclient "$dest"
cp -pu "$dest" "$1"
rm "$dest"
2
  • Can tramp deal with this?
    – phils
    Commented Feb 23, 2016 at 23:54
  • Doesn't look like it - s3 uses a proprietary protocol. Commented Feb 24, 2016 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.