git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
4c7aac877d29a76f055bc690eaa2d6a3bcb9287e blob 12642 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
 
git-maintenance(1)
==================

NAME
----
git-maintenance - Run tasks to optimize Git repository data


SYNOPSIS
--------
[verse]
'git maintenance' run [<options>]


DESCRIPTION
-----------
Run tasks to optimize Git repository data, speeding up other Git commands
and reducing storage requirements for the repository.

Git commands that add repository data, such as `git add` or `git fetch`,
are optimized for a responsive user experience. These commands do not take
time to optimize the Git data, since such optimizations scale with the full
size of the repository while these user commands each perform a relatively
small action.

The `git maintenance` command provides flexibility for how to optimize the
Git repository.

SUBCOMMANDS
-----------

register::
	Initialize Git config values so any scheduled maintenance will
	start running on this repository. This adds the repository to the
	`maintenance.repo` config variable in the current user's global
	config and enables some recommended configuration values for
	`maintenance.<task>.schedule`. The tasks that are enabled are safe
	for running in the background without disrupting foreground
	processes.
+
The `register` subcomand will also set the `maintenance.strategy` config
value to `incremental`, if this value is not previously set. The
`incremental` strategy uses the following schedule for each maintenance
task:
+
--
* `gc`: disabled.
* `commit-graph`: hourly.
* `prefetch`: hourly.
* `loose-objects`: daily.
* `incremental-repack`: daily.
--
+
`git maintenance register` will also disable foreground maintenance by
setting `maintenance.auto = false` in the current repository. This config
setting will remain after a `git maintenance unregister` command.

run::
	Run one or more maintenance tasks. If one or more `--task` options
	are specified, then those tasks are run in that order. Otherwise,
	the tasks are determined by which `maintenance.<task>.enabled`
	config options are true. By default, only `maintenance.gc.enabled`
	is true.

start::
	Start running maintenance on the current repository. This performs
	the same config updates as the `register` subcommand, then updates
	the background scheduler to run `git maintenance run --scheduled`
	on an hourly basis.

stop::
	Halt the background maintenance schedule. The current repository
	is not removed from the list of maintained repositories, in case
	the background maintenance is restarted later.

unregister::
	Remove the current repository from background maintenance. This
	only removes the repository from the configured list. It does not
	stop the background maintenance processes from running.

TASKS
-----

commit-graph::
	The `commit-graph` job updates the `commit-graph` files incrementally,
	then verifies that the written data is correct. The incremental
	write is safe to run alongside concurrent Git processes since it
	will not expire `.graph` files that were in the previous
	`commit-graph-chain` file. They will be deleted by a later run based
	on the expiration delay.

prefetch::
	The `prefetch` task updates the object directory with the latest
	objects from all registered remotes. For each remote, a `git fetch`
	command is run. The refmap is custom to avoid updating local or remote
	branches (those in `refs/heads` or `refs/remotes`). Instead, the
	remote refs are stored in `refs/prefetch/<remote>/`. Also, tags are
	not updated.
+
This is done to avoid disrupting the remote-tracking branches. The end users
expect these refs to stay unmoved unless they initiate a fetch.  With prefetch
task, however, the objects necessary to complete a later real fetch would
already be obtained, so the real fetch would go faster.  In the ideal case,
it will just become an update to bunch of remote-tracking branches without
any object transfer.

gc::
	Clean up unnecessary files and optimize the local repository. "GC"
	stands for "garbage collection," but this task performs many
	smaller tasks. This task can be expensive for large repositories,
	as it repacks all Git objects into a single pack-file. It can also
	be disruptive in some situations, as it deletes stale data. See
	linkgit:git-gc[1] for more details on garbage collection in Git.

loose-objects::
	The `loose-objects` job cleans up loose objects and places them into
	pack-files. In order to prevent race conditions with concurrent Git
	commands, it follows a two-step process. First, it deletes any loose
	objects that already exist in a pack-file; concurrent Git processes
	will examine the pack-file for the object data instead of the loose
	object. Second, it creates a new pack-file (starting with "loose-")
	containing a batch of loose objects. The batch size is limited to 50
	thousand objects to prevent the job from taking too long on a
	repository with many loose objects. The `gc` task writes unreachable
	objects as loose objects to be cleaned up by a later step only if
	they are not re-added to a pack-file; for this reason it is not
	advisable to enable both the `loose-objects` and `gc` tasks at the
	same time.

incremental-repack::
	The `incremental-repack` job repacks the object directory
	using the `multi-pack-index` feature. In order to prevent race
	conditions with concurrent Git commands, it follows a two-step
	process. First, it calls `git multi-pack-index expire` to delete
	pack-files unreferenced by the `multi-pack-index` file. Second, it
	calls `git multi-pack-index repack` to select several small
	pack-files and repack them into a bigger one, and then update the
	`multi-pack-index` entries that refer to the small pack-files to
	refer to the new pack-file. This prepares those small pack-files
	for deletion upon the next run of `git multi-pack-index expire`.
	The selection of the small pack-files is such that the expected
	size of the big pack-file is at least the batch size; see the
	`--batch-size` option for the `repack` subcommand in
	linkgit:git-multi-pack-index[1]. The default batch-size is zero,
	which is a special case that attempts to repack all pack-files
	into a single pack-file.

OPTIONS
-------
--auto::
	When combined with the `run` subcommand, run maintenance tasks
	only if certain thresholds are met. For example, the `gc` task
	runs when the number of loose objects exceeds the number stored
	in the `gc.auto` config setting, or when the number of pack-files
	exceeds the `gc.autoPackLimit` config setting. Not compatible with
	the `--schedule` option.

--schedule::
	When combined with the `run` subcommand, run maintenance tasks
	only if certain time conditions are met, as specified by the
	`maintenance.<task>.schedule` config value for each `<task>`.
	This config value specifies a number of seconds since the last
	time that task ran, according to the `maintenance.<task>.lastRun`
	config value. The tasks that are tested are those provided by
	the `--task=<task>` option(s) or those with
	`maintenance.<task>.enabled` set to true.

--quiet::
	Do not report progress or other information over `stderr`.

--task=<task>::
	If this option is specified one or more times, then only run the
	specified tasks in the specified order. If no `--task=<task>`
	arguments are specified, then only the tasks with
	`maintenance.<task>.enabled` configured as `true` are considered.
	See the 'TASKS' section for the list of accepted `<task>` values.


TROUBLESHOOTING
---------------
The `git maintenance` command is designed to simplify the repository
maintenance patterns while minimizing user wait time during Git commands.
A variety of configuration options are available to allow customizing this
process. The default maintenance options focus on operations that complete
quickly, even on large repositories.

Users may find some cases where scheduled maintenance tasks do not run as
frequently as intended. Each `git maintenance run` command takes a lock on
the repository's object database, and this prevents other concurrent
`git maintenance run` commands from running on the same repository. Without
this safeguard, competing processes could leave the repository in an
unpredictable state.

The background maintenance schedule runs `git maintenance run` processes
on an hourly basis. Each run executes the "hourly" tasks. At midnight,
that process also executes the "daily" tasks. At midnight on the first day
of the week, that process also executes the "weekly" tasks. A single
process iterates over each registered repository, performing the scheduled
tasks for that frequency. Depending on the number of registered
repositories and their sizes, this process may take longer than an hour.
In this case, multiple `git maintenance run` commands may run on the same
repository at the same time, colliding on the object database lock. This
results in one of the two tasks not running.

If you find that some maintenance windows are taking longer than one hour
to complete, then consider reducing the complexity of your maintenance
tasks. For example, the `gc` task is much slower than the
`incremental-repack` task. However, this comes at a cost of a slightly
larger object database. Consider moving more expensive tasks to be run
less frequently.

Expert users may consider scheduling their own maintenance tasks using a
different schedule than is available through `git maintenance start` and
Git configuration options. These users should be aware of the object
database lock and how concurrent `git maintenance run` commands behave.
Further, the `git gc` command should not be combined with
`git maintenance run` commands. `git gc` modifies the object database
but does not take the lock in the same way as `git maintenance run`. If
possible, use `git maintenance run --task=gc` instead of `git gc`.

The following sections describe the mechanisms put in place to run
background maintenance by `git maintenance start` and how to customize
them.

BACKGROUND MAINTENANCE ON POSIX SYSTEMS
---------------------------------------

The standard mechanism for scheduling background tasks on POSIX systems
is `cron`. This tool executes commands based on a given schedule. The
current list of user-scheduled tasks can be found by running `crontab -l`.
The schedule written by `git maintenance start` is similar to this:

-----------------------------------------------------------------------
# BEGIN GIT MAINTENANCE SCHEDULE
# The following schedule was created by Git
# Any edits made in this region might be
# replaced in the future by a Git command.

0 1-23 * * * "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=hourly
0 0 * * 1-6 "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=daily
0 0 * * 0 "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=weekly

# END GIT MAINTENANCE SCHEDULE
-----------------------------------------------------------------------

The comments are used as a region to mark the schedule as written by Git.
Any modifications within this region will be completely deleted by
`git maintenance stop` or overwritten by `git maintenance start`.

The `<path>` string is loaded to specifically use the location for the
`git` executable used in the `git maintenance start` command. This allows
for multiple versions to be compatible. However, if the same user runs
`git maintenance start` with multiple Git executables, then only the
latest executable will be used.

These commands use `git for-each-repo --config=maintenance.repo` to run
`git maintenance run --schedule=<frequency>` on each repository listed in
the multi-valued `maintenance.repo` config option. These are typically
loaded from the user-specific global config located at `~/.gitconfig`.
The `git maintenance` process then determines which maintenance tasks
are configured to run on each repository with each `<frequency>` using
the `maintenance.<task>.schedule` config options. These values are loaded
from the global or repository config values.

If the config values are insufficient to achieve your desired background
maintenance schedule, then you can create your own schedule. If you run
`crontab -e`, then an editor will load with your user-specific `cron`
schedule. In that editor, you can add your own schedule lines. You could
start by adapting the default schedule listed earlier, or you could read
https://man7.org/linux/man-pages/man5/crontab.5.html[the `crontab` documentation]
for advanced scheduling techniques. Please do use the full path and
`--exec-path` techniques from the default schedule to ensure you are
executing the correct binaries in your schedule.


GIT
---
Part of the linkgit:git[1] suite
debug log:

solving 4c7aac877d ...
found 4c7aac877d in https://public-inbox.org/git/99170df4626544c1dc26d2e188b215a776140a32.1605647598.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/709a17372099351af3e3b9f2dddcd9ce220a9fcb.1604520368.git.gitgitgadget@gmail.com/
found 6fec1eb8dc in git.git.git
preparing index
index prepared:
100644 6fec1eb8dc288757a2d0b4dbbf5faf18a8904df5	Documentation/git-maintenance.txt

applying [1/2] https://public-inbox.org/git/99170df4626544c1dc26d2e188b215a776140a32.1605647598.git.gitgitgadget@gmail.com/
diff --git a/Documentation/git-maintenance.txt b/Documentation/git-maintenance.txt
index 6fec1eb8dc..4c7aac877d 100644

Checking patch Documentation/git-maintenance.txt...
Applied patch Documentation/git-maintenance.txt cleanly.

skipping https://public-inbox.org/git/709a17372099351af3e3b9f2dddcd9ce220a9fcb.1604520368.git.gitgitgadget@gmail.com/ for 4c7aac877d
index at:
100644 4c7aac877d29a76f055bc690eaa2d6a3bcb9287e	Documentation/git-maintenance.txt

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).