repack: avoid loosening promisor objects in partial clones

When `git repack -A -d` is run in a partial clone, `pack-objects`
is invoked twice: once to repack all promisor objects, and once to
repack all non-promisor objects. The latter `pack-objects` invocation
is with --exclude-promisor-objects and --unpack-unreachable, which
loosens all objects unused during this invocation. Unfortunately,
this includes promisor objects.

Because the -d argument to `git repack` subsequently deletes all loose
objects also in packs, these just-loosened promisor objects will be
immediately deleted. However, this extra disk churn is unnecessary in
the first place.  For example, in a newly-cloned partial repo that
filters all blob objects (e.g. `--filter=blob:none`), `repack` ends up
unpacking all trees and commits into the filesystem because every
object, in this particular case, is a promisor object. Depending on
the repo size, this increases the disk usage considerably: In my copy
of the linux.git, the object directory peaked 26GB of more disk usage.

In order to avoid this extra disk churn, pass the names of the promisor
packfiles as --keep-pack arguments to the second invocation of
`pack-objects`. This informs `pack-objects` that the promisor objects
are already in a safe packfile and, therefore, do not need to be
loosened.

For testing, we need to validate whether any object was loosened.
However, the "evidence" (loosened objects) is deleted during the
process which prevents us from inspecting the object directory.
Instead, let's teach `pack-objects` to count loosened objects and
emit via trace2 thus allowing inspecting the debug events after the
process is finished. This new event is used on the added regression
test.

Lastly, add a new perf test to evaluate the performance impact
made by this changes (tested on git.git):

     Test          HEAD^                 HEAD
     ----------------------------------------------------------
     5600.3: gc    134.38(41.93+90.95)   7.80(6.72+1.35) -94.2%

For a bigger repository, such as linux.git, the improvement is
even bigger:

     Test          HEAD^                     HEAD
     -------------------------------------------------------------------
     5600.3: gc    6833.00(918.07+3162.74)   268.79(227.02+39.18) -96.1%

These improvements are particular big because every object in the
newly-cloned partial repository is a promisor object.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Helped-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Rafael Silva <rafaeloliveira.cs@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 files changed
tree: 4e472c97217e778daeb3b6da72db3b9d8613de79
  1. .github/
  2. block-sha1/
  3. builtin/
  4. ci/
  5. compat/
  6. contrib/
  7. Documentation/
  8. ewah/
  9. git-gui/
  10. gitk-git/
  11. gitweb/
  12. mergetools/
  13. negotiator/
  14. perl/
  15. po/
  16. ppc/
  17. refs/
  18. sha1dc/
  19. sha256/
  20. t/
  21. templates/
  22. trace2/
  23. xdiff/
  24. .cirrus.yml
  25. .clang-format
  26. .editorconfig
  27. .gitattributes
  28. .gitignore
  29. .gitmodules
  30. .mailmap
  31. .travis.yml
  32. .tsan-suppressions
  33. abspath.c
  34. aclocal.m4
  35. add-interactive.c
  36. add-interactive.h
  37. add-patch.c
  38. advice.c
  39. advice.h
  40. alias.c
  41. alias.h
  42. alloc.c
  43. alloc.h
  44. apply.c
  45. apply.h
  46. archive-tar.c
  47. archive-zip.c
  48. archive.c
  49. archive.h
  50. attr.c
  51. attr.h
  52. banned.h
  53. base85.c
  54. bisect.c
  55. bisect.h
  56. blame.c
  57. blame.h
  58. blob.c
  59. blob.h
  60. bloom.c
  61. bloom.h
  62. branch.c
  63. branch.h
  64. builtin.h
  65. bulk-checkin.c
  66. bulk-checkin.h
  67. bundle.c
  68. bundle.h
  69. cache-tree.c
  70. cache-tree.h
  71. cache.h
  72. chdir-notify.c
  73. chdir-notify.h
  74. check-builtins.sh
  75. check_bindir
  76. checkout.c
  77. checkout.h
  78. chunk-format.c
  79. chunk-format.h
  80. CODE_OF_CONDUCT.md
  81. color.c
  82. color.h
  83. column.c
  84. column.h
  85. combine-diff.c
  86. command-list.txt
  87. commit-graph.c
  88. commit-graph.h
  89. commit-reach.c
  90. commit-reach.h
  91. commit-slab-decl.h
  92. commit-slab-impl.h
  93. commit-slab.h
  94. commit.c
  95. commit.h
  96. common-main.c
  97. config.c
  98. config.h
  99. config.mak.dev
  100. config.mak.in
  101. config.mak.uname
  102. configure.ac
  103. connect.c
  104. connect.h
  105. connected.c
  106. connected.h
  107. convert.c
  108. convert.h
  109. copy.c
  110. COPYING
  111. credential.c
  112. credential.h
  113. csum-file.c
  114. csum-file.h
  115. ctype.c
  116. daemon.c
  117. date.c
  118. decorate.c
  119. decorate.h
  120. delta-islands.c
  121. delta-islands.h
  122. delta.h
  123. detect-compiler
  124. diff-delta.c
  125. diff-lib.c
  126. diff-merges.c
  127. diff-merges.h
  128. diff-no-index.c
  129. diff.c
  130. diff.h
  131. diffcore-break.c
  132. diffcore-delta.c
  133. diffcore-order.c
  134. diffcore-pickaxe.c
  135. diffcore-rename.c
  136. diffcore-rotate.c
  137. diffcore.h
  138. dir-iterator.c
  139. dir-iterator.h
  140. dir.c
  141. dir.h
  142. editor.c
  143. entry.c
  144. entry.h
  145. environment.c
  146. environment.h
  147. exec-cmd.c
  148. exec-cmd.h
  149. fetch-negotiator.c
  150. fetch-negotiator.h
  151. fetch-pack.c
  152. fetch-pack.h
  153. fmt-merge-msg.c
  154. fmt-merge-msg.h
  155. fsck.c
  156. fsck.h
  157. fsmonitor.c
  158. fsmonitor.h
  159. fuzz-commit-graph.c
  160. fuzz-pack-headers.c
  161. fuzz-pack-idx.c
  162. generate-cmdlist.sh
  163. generate-configlist.sh
  164. gettext.c
  165. gettext.h
  166. git-add--interactive.perl
  167. git-archimport.perl
  168. git-bisect.sh
  169. git-compat-util.h
  170. git-cvsexportcommit.perl
  171. git-cvsimport.perl
  172. git-cvsserver.perl
  173. git-difftool--helper.sh
  174. git-filter-branch.sh
  175. git-instaweb.sh
  176. git-merge-octopus.sh
  177. git-merge-one-file.sh
  178. git-merge-resolve.sh
  179. git-mergetool--lib.sh
  180. git-mergetool.sh
  181. git-p4.py
  182. git-quiltimport.sh
  183. git-rebase--preserve-merges.sh
  184. git-request-pull.sh
  185. git-send-email.perl
  186. git-sh-i18n.sh
  187. git-sh-setup.sh
  188. git-submodule.sh
  189. git-svn.perl
  190. GIT-VERSION-GEN
  191. git-web--browse.sh
  192. git.c
  193. git.rc
  194. gpg-interface.c
  195. gpg-interface.h
  196. graph.c
  197. graph.h
  198. grep.c
  199. grep.h
  200. hash-lookup.c
  201. hash-lookup.h
  202. hash.h
  203. hashmap.c
  204. hashmap.h
  205. help.c
  206. help.h
  207. hex.c
  208. http-backend.c
  209. http-fetch.c
  210. http-push.c
  211. http-walker.c
  212. http.c
  213. http.h
  214. ident.c
  215. imap-send.c
  216. INSTALL
  217. iterator.h
  218. json-writer.c
  219. json-writer.h
  220. khash.h
  221. kwset.c
  222. kwset.h
  223. levenshtein.c
  224. levenshtein.h
  225. LGPL-2.1
  226. line-log.c
  227. line-log.h
  228. line-range.c
  229. line-range.h
  230. linear-assignment.c
  231. linear-assignment.h
  232. list-objects-filter-options.c
  233. list-objects-filter-options.h
  234. list-objects-filter.c
  235. list-objects-filter.h
  236. list-objects.c
  237. list-objects.h
  238. list.h
  239. ll-merge.c
  240. ll-merge.h
  241. lockfile.c
  242. lockfile.h
  243. log-tree.c
  244. log-tree.h
  245. ls-refs.c
  246. ls-refs.h
  247. mailinfo.c
  248. mailinfo.h
  249. mailmap.c
  250. mailmap.h
  251. Makefile
  252. match-trees.c
  253. mem-pool.c
  254. mem-pool.h
  255. merge-blobs.c
  256. merge-blobs.h
  257. merge-ort-wrappers.c
  258. merge-ort-wrappers.h
  259. merge-ort.c
  260. merge-ort.h
  261. merge-recursive.c
  262. merge-recursive.h
  263. merge.c
  264. mergesort.c
  265. mergesort.h
  266. midx.c
  267. midx.h
  268. name-hash.c
  269. notes-cache.c
  270. notes-cache.h
  271. notes-merge.c
  272. notes-merge.h
  273. notes-utils.c
  274. notes-utils.h
  275. notes.c
  276. notes.h
  277. object-file.c
  278. object-name.c
  279. object-store.h
  280. object.c
  281. object.h
  282. oid-array.c
  283. oid-array.h
  284. oidmap.c
  285. oidmap.h
  286. oidset.c
  287. oidset.h
  288. pack-bitmap-write.c
  289. pack-bitmap.c
  290. pack-bitmap.h
  291. pack-check.c
  292. pack-objects.c
  293. pack-objects.h
  294. pack-revindex.c
  295. pack-revindex.h
  296. pack-write.c
  297. pack.h
  298. packfile.c
  299. packfile.h
  300. pager.c
  301. parse-options-cb.c
  302. parse-options.c
  303. parse-options.h
  304. patch-delta.c
  305. patch-ids.c
  306. patch-ids.h
  307. path.c
  308. path.h
  309. pathspec.c
  310. pathspec.h
  311. pkt-line.c
  312. pkt-line.h
  313. preload-index.c
  314. pretty.c
  315. pretty.h
  316. prio-queue.c
  317. prio-queue.h
  318. progress.c
  319. progress.h
  320. promisor-remote.c
  321. promisor-remote.h
  322. prompt.c
  323. prompt.h
  324. protocol.c
  325. protocol.h
  326. prune-packed.c
  327. prune-packed.h
  328. quote.c
  329. quote.h
  330. range-diff.c
  331. range-diff.h
  332. reachable.c
  333. reachable.h
  334. read-cache.c
  335. README.md
  336. rebase-interactive.c
  337. rebase-interactive.h
  338. rebase.c
  339. rebase.h
  340. ref-filter.c
  341. ref-filter.h
  342. reflog-walk.c
  343. reflog-walk.h
  344. refs.c
  345. refs.h
  346. refspec.c
  347. refspec.h
  348. remote-curl.c
  349. remote.c
  350. remote.h
  351. replace-object.c
  352. replace-object.h
  353. repo-settings.c
  354. repository.c
  355. repository.h
  356. rerere.c
  357. rerere.h
  358. reset.c
  359. reset.h
  360. resolve-undo.c
  361. resolve-undo.h
  362. revision.c
  363. revision.h
  364. run-command.c
  365. run-command.h
  366. SECURITY.md
  367. send-pack.c
  368. send-pack.h
  369. sequencer.c
  370. sequencer.h
  371. serve.c
  372. serve.h
  373. server-info.c
  374. setup.c
  375. sh-i18n--envsubst.c
  376. sha1dc_git.c
  377. sha1dc_git.h
  378. shallow.c
  379. shallow.h
  380. shell.c
  381. shortlog.h
  382. sideband.c
  383. sideband.h
  384. sigchain.c
  385. sigchain.h
  386. simple-ipc.h
  387. split-index.c
  388. split-index.h
  389. stable-qsort.c
  390. strbuf.c
  391. strbuf.h
  392. streaming.c
  393. streaming.h
  394. string-list.c
  395. string-list.h
  396. strmap.c
  397. strmap.h
  398. strvec.c
  399. strvec.h
  400. sub-process.c
  401. sub-process.h
  402. submodule-config.c
  403. submodule-config.h
  404. submodule.c
  405. submodule.h
  406. symlinks.c
  407. tag.c
  408. tag.h
  409. tar.h
  410. tempfile.c
  411. tempfile.h
  412. thread-utils.c
  413. thread-utils.h
  414. tmp-objdir.c
  415. tmp-objdir.h
  416. trace.c
  417. trace.h
  418. trace2.c
  419. trace2.h
  420. trailer.c
  421. trailer.h
  422. transport-helper.c
  423. transport-internal.h
  424. transport.c
  425. transport.h
  426. tree-diff.c
  427. tree-walk.c
  428. tree-walk.h
  429. tree.c
  430. tree.h
  431. unicode-width.h
  432. unimplemented.sh
  433. unix-socket.c
  434. unix-socket.h
  435. unix-stream-server.c
  436. unix-stream-server.h
  437. unpack-trees.c
  438. unpack-trees.h
  439. upload-pack.c
  440. upload-pack.h
  441. url.c
  442. url.h
  443. urlmatch.c
  444. urlmatch.h
  445. usage.c
  446. userdiff.c
  447. userdiff.h
  448. utf8.c
  449. utf8.h
  450. varint.c
  451. varint.h
  452. version.c
  453. version.h
  454. versioncmp.c
  455. walker.c
  456. walker.h
  457. wildmatch.c
  458. wildmatch.h
  459. worktree.c
  460. worktree.h
  461. wrap-for-bin.sh
  462. wrapper.c
  463. write-or-die.c
  464. ws.c
  465. wt-status.c
  466. wt-status.h
  467. xdiff-interface.c
  468. xdiff-interface.h
  469. zlib.c
README.md

Build status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-<commandname>.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://lore.kernel.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks