Git is doing very slow commits on a Samba share. What can I do to speed it up?
Asked Answered
D

4

12

I am running a git repository on a remote server. I have it set up a samba share on the remote server so I can save my code there instead of on my local windows 7 machine. We are trying to look into using git, because svn has been so slow and unreliable. The problem that we are having with git is that doing any commits/clones/pulls onto the samba share run super super slow. If i do a commit/clone/pull onto a local dir on my windows 7 machine it works great, but we need the code to be on the remote server. Any ideas? I could really use it.

Edit:

I should also mention that I have already ran git gc --aggressive and it hasn't sped it up.

Dada answered 23/8, 2012 at 16:7 Comment(3)
Do you run git commands on the server and repo is on server's drive? Or you run commands locally, but the repo is on shared server's drive? You should do first.Plusch
I run the git commands on a local machine, which adjusts code on a samba share, the samba share is hosted on a web development server so we can see what our code does. Each developer has their own folder on the share. We push our changes to a remote server where we store our repo.Dada
Yes, it's wrong way to do it. Maybe you could do vice versa - have repo locally, but the web-server will use shared folder of dev's computer. Otherwise you would have other performance issues, e.g. find-in-files works much faster on local drive than shared.Plusch
R
3

Git is not meant to be used in this configuration. It's like getting a Formula 1 and have it race on a dirt road.

Git is a DVCS, or distributed version control. In other words, every developer gets a clone.

What you need to do is setup a git server repository on that samba machine and access the repo via http or ssh

You can use projects like GitBlit or even better an account on Github

Ritual answered 23/8, 2012 at 16:9 Comment(8)
We need to run it remotely because its a webserver. Our individual machines are not web servers.Dada
I don't get it. only the git server needs to be web enabled. the clients use http/ssh to access itRitual
Each individual developer will have a clone of the repo. They store that clone on the web server so they can test their code before they push it to all the other developers. We all use Samba shares to access our code on our local machines. I have setup a remote repository that is not on the web server, but is there solely to hold the code.Dada
That's still not how git works. You don't store your clone on the server, you push the changes to the repository. If you need to test, you should be running the tests locally, as a commit hook, etc.Dashtikavir
The right thing to do - let developers have all environment locally so they could do everything on their computers.Plusch
bottom line, don't use SAMBA shares, use GitBlit - Gitblit is an open-source, pure Java stack for managing, viewing, and serving Git repositories.Ritual
Vagrant might help the local developers to set up their own webservers for testing. Then the code would be locally and pulled into the webserver on a virtual machine.Kohl
Reason for keeping the clone on a samba drive - sharing amongst many different system. Suppose I change some code. I can build THAT code on windows, linux, solaris, aix, hpux, freebsd, etc. All by mounting that share to the various servers (via smb or nfs, depending which OS I'm dealing with). Fewer commits (because git seems to hate me and always gives me a hard time with any little thing) and lets me tune and tweak things for a target OS, then commit to our central repo from my prime development machine, without having to have git installed everywhere.Oxidize
H
3

I had the same problem with Git's performance over SMB shares. Unfortunately I can't run the development code on my local machine, so I use SMB to mount the remote directory and edit the source files using a proper text editor on my local machine.

Since I want some comfort when committing to the repository, I prefer a GUI client which runs on my local machine. With the mentioned performance problems this is a bit tricky, though, and takes a lot of time.

However: I found a sleek little workaround. Before committing anything to the repository, I pull a copy of the remote sources to my local hard drive using rsync, like this:

rsync -az --progress --exclude ".git" [email protected]:/home/myapp/sourcecode /Devel/portal-mirror

That way it takes less than a second to do a full 1-to-1 sync of the remote state (bound this to a keyboard shortcut in my Git app) before doing the diffs and commits. Works like a charm. After committing and pushing to the repository I just do git reset --hard and git pull on the dev server to sync the changes back.

Hoskinson answered 11/7, 2013 at 15:47 Comment(0)
G
2

We are running the same configuration with git and samba in combination with php-storm. Its running quite well. Only when i try to use "SourceTree" on our huge project it takes ages to refresh, because (i think) git scanns each and every single file to do so.

One thing i tried, and i got minor performance improvements out of it, was to tune the samba server a little bit:

Config File:

socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536

Found that line when looking for samba speedup.

Another solution might be a constant 1 on 1 sync which runs all the time in background kindof replacing samba. Maybe the rsync could be modified somewhat to do so.

Goles answered 22/1, 2014 at 9:32 Comment(0)
M
0

You might consider reversing the paradigm a bit and having the web server mount shares on the developers' machines. That way all the cloning/committing/coding is done locally, but each developer's site is simply hosted off of a share.

Right now I assume your webserver is exposing each website's root directory as a samba share. A developer then mounts that share on his or her local machine, clones some repository, and works off of the share. Performance in that case is going to be poor at best, and you may also run into problems with byte range locking requests (BRL) and such.

Instead, an option is to clone directly to a directory on each developer's computer, and share that directory. The web server then mounts that share.

Of course ideally each developer would run his or her own instance of the web server, but if I'm reading the questions correctly maybe that's not an option in this case.

Midstream answered 26/9, 2017 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.