builtin/pack-objects.c: avoid iterating all refs

In git-pack-objects, we iterate over all the tags if the --include-tag
option is passed on the command line. For some reason this uses
for_each_ref which is expensive if the repo has many refs. We should
use for_each_tag_ref instead.

Because the add_ref_tag callback will now only visit tags we
simplified it a bit.

The motivation for this change is that we observed performance issues
with a repository on gitlab.com that has 500,000 refs but only 2,000
tags. The fetch traffic on that repo is dominated by CI, and when we
changed CI to fetch with 'git fetch --no-tags' we saw a dramatic
change in the CPU profile of git-pack-objects. This lead us to this
particular ref walk. More details in:
https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/746#note_483546598

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