This repository has been archived by the owner. It is now read-only.
Browse files

readme: Document Git memory issues (git-gc)

  • Loading branch information...
Krinkle committed Nov 30, 2017
1 parent dad746f commit b33d479cb956ccb25c2ebd3af967958a29aee678
Showing with 39 additions and 1 deletion.
  1. +39 −1
@@ -1,7 +1,8 @@
[![Build Status](](
# Snapshots

## Install:
## Install

* Copy `sample-config.php` and rename to `config.php`
* Edit `config.php` and change the directory paths if needed (and ensure they exist).
Keep in mind that the PHP script needs to be able to read, write, and remove files
@@ -15,3 +16,40 @@
* Schedule updateSnaphots.php to run hourly<br>
`0 * * * * php /path/to/mw-tool-snapshots/scripts/updateSnaphots.php > {logsDir}/updateSnaphots.log 2>&1`
* Symlink `./public_html` to be, or inside of, `/path/to/your/public_html`

## Git memory

The `updateSnaphots.php` uses Git for many of its tasks. By default, Git
will periodically run `git-gc` as part of an otherwise unrelated Git command.
This sub process can take up a substantial amount of memory, and if you
run the update script in an environment with limited memory, it may end up
crashing as a result.

Further reading:
* [git-gc](, [git-repack](, and [git-pack-objects](
* StackOverflow [q/3095737](, [q/8214321](, and [q/42175296](

In short:
* Set `pack.threads = 1` to restrict git-gc to one `git-pack-objects` thread.
* Set `pack.windowMemory` to `256m` (or other value, as needed) to restrict
how much memory may be at the same time. Other internal values are dynamically
derived from this.

To set these configurations for the the `mediawikiCoreRepoDir` directory only, use:

cd ~/src/snapshots/remotes/mediawiki/
git config --local --add pack.threads 1
git config --local --add pack.windowMemory 256m
# Confirm
git config --local -l

Or, without changing directories:

GIT_DIR=~/src/snapshots/remotes/mediawiki/.git git config --local --add pack.threads 1
GIT_DIR=~/src/snapshots/remotes/mediawiki/.git git config --local --add pack.windowMemory 256m
# Confirm
GIT_DIR=~/src/snapshots/remotes/mediawiki/.git git config --local -l

0 comments on commit b33d479

Please sign in to comment.