packfile: track packs via the MRU list exclusively

We track packfiles via two different lists:

  - `struct packfile_store::packs` is a list that sorts local packs
    first. In addition, these packs are sorted so that younger packs are
    sorted towards the front.

  - `struct packfile_store::mru` is a list that sorts packs so that
    most-recently used packs are at the front.

The reasoning behind the ordering in the `packs` list is that younger
objects stored in the local object store tend to be accessed more
frequently, and that is certainly true for some cases. But there are
going to be lots of cases where that isn't true. Especially when
traversing history it is likely that one needs to access many older
objects, and due to our housekeeping it is very likely that almost all
of those older objects will be contained in one large pack that is
oldest.

So whether or not the ordering makes sense really depends on the use
case at hand. A flexible approach like our MRU list addresses that need,
as it will sort packs towards the front that are accessed all the time.
Intuitively, this approach is thus able to satisfy more use cases more
efficiently.

This reasoning casts some doubt on whether or not it really makes sense
to track packs via two different lists. It causes confusion, and it is
not clear whether there are use cases where the `packs` list really is
such an obvious choice.

Merge these two lists into one most-recently-used list.

Note that there is one important edge case: `for_each_packed_object()`
uses the MRU list to iterate through packs, and then it lists each
object in those packs. This would have the effect that we now sort the
current pack towards the front, thus modifying the list of packfiles we
are iterating over, with the consequence that we'll see an infinite
loop. This edge case is worked around by introducing a new field that
allows us to skip updating the MRU.

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

Those wishing to help with error message, usage and informational message string translations (localization l10) should see po/README.md (a po file is a Portable Object file that holds the translations).

To subscribe to the list, send an email to git+subscribe@vger.kernel.org (see https://subspace.kernel.org/subscribing.html for details). The mailing list archives are available at https://lore.kernel.org/git/, https://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