dingjie / atom-sync

Atom package to sync files bidirectionally between remote host and local over ssh+rsync
MIT License
59 stars 32 forks source link

Feaure Request: persistent connection for faster sync #68

Open CarloLucibello opened 7 years ago

CarloLucibello commented 7 years ago

This is how Sublime FTP, as they claim on their web page https://wbond.net/sublime_packages/sftp

Maybe some inspiration can be found here https://atom.io/packages/remote-atom

Bye, Carlo

ayurmedia commented 7 years ago

whats the problem, rsync is pretty fast. it has a process running on the server and only transfers the differences. i don't know if keep-alive helps much, rsync connects fast enough for me.

Editing a File of 20kb (650lines) , one character results in a transfer of 200bytes (seems to be the overhead of the rsync protocol).

sent 227 bytes received 202 bytes 286.00 bytes/sec total size is 19,283 speedup is 44.95

how much faster do you expect it to be ?

CarloLucibello commented 7 years ago

at least in my case, the bottleneck is not the transfer rate, but the time it takes to establish the connection

ayurmedia commented 7 years ago

Probably nothing to do in the plugin / rsync itself, but you can try to optimize your ssh config, because rsync is using ssh for transfering data:

https://superuser.com/questions/576479/how-to-keep-rsync-over-ssh-connection-permanent-no-broken-pipe

This works providing your running OpenSSH.

Edit your ~/.ssh/config file and add the following to activate 
the keep-alive system for just your user for all host connected to.

If you want to do this just for one host, 
switch the * with a host name of your choosing.

Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2

https://stackoverflow.com/questions/24211056/keep-multiple-ssh-connections-alive-for-future-commands

w-barath commented 7 years ago

I tried @ayurmedia's suggestion and all it didn't reduce connection times at all.

$ (time ssh remote "exit") 2>&1 | grep real
real    0m1.157s
$ (time ssh remote "exit") 2>&1 | grep real
real    0m1.154s
$

What it did do was cause me to accumulate a bunch of waiting connections (check tcpdump -t)

@CarloLucibello, if you look toward the bottom of the front page of the project you'll see this:

Config sample of ~/.ssh/config

Host *
    ControlMaster auto
    ControlPath ~/.ssh/ssh-%r@%h:%p
    ControlPersist 10m
    ServerAliveInterval 30

I tried this and my connection time drops from 1154ms with to 235ms. Awesome!

$ (time ssh remote "exit") 2>&1 | grep real
real    0m0.237s
CarloLucibello commented 7 years ago

@w-barath thanks, for me the drop is from 10s to 0.1s

ayurmedia commented 7 years ago

Same here, i have a server where ssh-connection is very slow. With this ControlPersistant now it is very fast when you managed to connect once.