This repository has been archived by the owner. It is now read-only.
Permalink
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 README.md
@@ -1,7 +1,8 @@
[![Build Status](https://travis-ci.org/Krinkle/mw-tool-snapshots.svg?branch=master)](https://travis-ci.org/Krinkle/mw-tool-snapshots)
# 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](https://git-scm.com/docs/git-gc), [git-repack](https://git-scm.com/docs/git-repack), and [git-pack-objects](https://git-scm.com/docs/git-pack-objects)
* StackOverflow [q/3095737](https://stackoverflow.com/q/3095737/319266), [q/8214321](https://stackoverflow.com/q/8214321/319266), and [q/42175296](https://stackoverflow.com/q/42175296/319266).

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.