bcpierce00 / unison

Unison file synchronizer
GNU General Public License v3.0
4.02k stars 227 forks source link

Limit the RAM memory #24

Closed wicope closed 8 years ago

wicope commented 8 years ago

Hi.

I have some server with low RAM memory. Unison consume all RAM memory (a lot RAM) and pulls me down servers. Please How i can limit the RAM memory for Unison?.

Server with 100% of RAM and Unison consume 50%. Example: Server with 1GB of RAM and Unison consume ~500MB or >500MB. Example: Server with 3GB of RAM and Unison consume ~1.5GB or >1.5GB.

I start the server then unison have low consume of RAM. When the server fails (There is insufficient memory) then i see high consume of RAM of unison.

Regards.

alkuzad commented 8 years ago

I do not see this behaviour on my setup, can you share more about yours ?

wicope commented 8 years ago
$ unison -version
unison version 2.48.3
$ cat ~/.cccc/cccc.prf 

root = /media/cccc/cccc
root = ssh://root@111.111.1.111//data/cccc

prefer = newer
repeat = 2
terse = true
dontchmod = true
perms = 0
ignore = Name *.sock
logfile = /var/log/unison/cccc.log

start unison:

rm -rf $HOME/.cccc
create ~/.cccc/cccc.prf 
ssh root@111.111.1.111 rm -rf /root/.unison/*
UNISON="$HOME/.cccc" unison cccc-project > /dev/null 2>&1 &
alkuzad commented 8 years ago

I do not see anything unusual, you should enable back the messages and look what files cause this memory consumption.

Also have in mind that Unison was optimized to synchronize small files very fast, if you synchronize media data you could read http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#speeding about using rsync for synchronizing big files.

wicope commented 8 years ago

Hi alkuzad.

The files are small. Yes is good idea see the messages and look what files cause this memory consumption.

I see the total of RAM: top -o %MEM

How i can see how much RAM consume each file in synchronization? unison -debug verbose (i will try soon)?

wicope commented 8 years ago

Hi

I see nothing on the consumption of RAM with unison -debug verbose.

What i can do for limit the RAM? Change any parameter of setup? The OS should limit the RAM for unison process? How i can see the memory consumption of unison in detail? Other things are wellcome. Thank you alkuzad for your help.

More info about setup:

cat /var/log/unison/cccc-unison-debug.log 
[startup] Preferences:
ui = graphic
host = 
server = false
prefsdocs = false
doc = 
version = false
silent = false
dumbtty = false
testserver = false
rest = cccc-project
showprev = false
selftest = false
confirmmerge = false
retry = 0
repeat = 2
contactquietly = false
key = 
label = 
expert = false
height = 15
auto = false
maxthreads = 0
maxsizethreshold = -1
prefer = newer
force = 
sortnewfirst = false
sortbysize = false
keeptempfilesaftermerge = false
diff = diff -u CURRENT2 CURRENT1
copyonconflict = false
backupdir = 
maxbackups = 2
backups = false
backupsuffix = 
backupprefix = .bak.$VERSION.
backuploc = central
copymax = 1
copyquoterem = default
copythreshold = -1
copyprogrest = rsync --partial --append-verify --compress
copyprog = rsync --partial --inplace --compress
rsync = true
fastcheck = default
ignorelocks = false
dumparchives = false
showarchive = false
rootsName = 
ignorearchives = false
fastercheckUNSAFE = false
fat = false
allHostsAreRunningWindows = false
someHostIsRunningWindows = false
ignore = Name *.sock
confirmbigdel = true
batch = false
root = ssh://root@111.111.1.111//home/cccc/cccc
root = /media/cccc/cccc
killserver = false
halfduplex = false
stream = true
addversionno = false
servercmd = 
sshargs = 
rshargs = 
rshcmd = rsh
sshcmd = ssh
xferbycopying = true
sshversion = 
clientHostName = wicope
ignoreinodenumbers = false
links-aux = true
links = default
times = false
group = false
owner = false
numericids = false
dontchmod = true
perms = 0
watch = true
rsrc-aux = false
rsrc = default
maxerrors = 1
unicodeCS = false
unicodeEnc = false
unicode = default
someHostIsInsensitive = false
ignorecase = default
timers = false
terse = true
logfile = /var/log/unison/cccc-unison.log
log = true
debugtimes = false
debug = verbose
addprefsto = 
alkuzad commented 8 years ago

On Linux machine you can use cgroups to limit memory consumption: https://wiki.archlinux.org/index.php/Cgroups

just create user "unison" on both sides and setup cgroup for it.

Config look fine, you could try disabling watch functionality and run unison from cron only if you do not need instant sync.

wicope commented 8 years ago

I will try. Close the issues because It will take time to do. Thanks you alkuzad

bcpierce00 commented 8 years ago

You can also use ulimit to directly limit the memory used by a particular process. When running with -verbose you should also see message from the garbage collector about when collections are occurring and how big the heap is growing.