git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Stefan Beller" <sbeller@google.com>, "Jeff King" <peff@peff.net>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"David Turner" <novalis@novalis.org>,
	git@vger.kernel.org, "Michael Haggerty" <mhagger@alum.mit.edu>
Subject: [PATCH 00/23] Prepare to separate out a packed_ref_store
Date: Wed, 17 May 2017 14:05:23 +0200	[thread overview]
Message-ID: <cover.1495014840.git.mhagger@alum.mit.edu> (raw)

This patch series is the next leg on a journey towards reading
`packed-refs` using `mmap()`, the most interesting aspect of which is
that we will often be able to avoid having to read the whole
`packed-refs` file if we only need a subset of references.

The first leg of the journey was separating out the reference cache
into a separate module [1]. That branch is already merged to master.

This patch series prepares the ground for separating out a
`packed_ref_store`, but doesn't yet take that step. (As you can see,
it's a long enough patch series already!) It's kind of a grab bag of
cleanup patches plus work to decouple the packed-refs handling code
from the rest of `files_ref_store`. Some highlights:

* Patch 07/23 adds a log message parameter to `refs_delete_refs()` and
  `delete_refs()`, for consistency with other reference-changing
  operations. Even though `files_ref_store` is incapable of storing
  reflogs for deleted references, that is no reason that the API
  shouldn't admit the possibility for future backends.

* Patch 12/23 breaks `ref_transaction_commit()` into multiple
  functions:

  * `ref_transaction_prepare()`: do pre-checks, obtain locks, etc.; do
    everything possible to make sure that the reference update will be
    successful.

  * `ref_transaction_finish()`: actually commit a prepared
    transaction.

  * `ref_transaction_abort()`: abort a prepared transaction.

  This separation will be useful for supporting a "compound" reference
  store composed of multiple reference stores that work together
  (i.e., one for loose refs and one for packed refs).

* Patch 17/23 changes `get_packed_ref_cache()` to skip `lstat()`ing
  the packed-refs file (to check its freshness) if we already have it
  locked.

* Patch 19/23 fixes the error handling in `read_packed_refs()`: if
  `fopen()` fails due to `ENOENT`, then there are no packed refs. But
  if it fails for another reason, that is a problem that should be
  reported to the user.

* Patch 22/23 (by Peff) changes ref-filter to attempt to limit the
  reference traversal to a prefix, if there is a single
  `match_as_path` pattern that starts with non-glob characters. This
  limits the number of loose references that need to be read when
  processing a command like `git for-each-ref refs/heads/`.

* Patch 23/23 makes `cache_ref_iterator` smarter about avoiding
  "priming" directories of loose references that won't be needed,
  further reducing the number of loose references that need to be read
  in some cases of iterating over references.

These changes are also available as branch `packed-ref-store-prep` in
my GitHub fork [2]. If you'd like to see a preview of the rest of the
changes (which works but is not yet polished), checkout the
`mmap-packed-refs` branch from the same place.

Michael

[1] http://public-inbox.org/git/cover.1490026594.git.mhagger@alum.mit.edu/
    http://public-inbox.org/git/cover.1490966385.git.mhagger@alum.mit.edu/
    http://public-inbox.org/git/cover.1492323985.git.mhagger@alum.mit.edu/

[2] https://github.com/mhagger/git

Jeff King (1):
  ref-filter: limit traversal to prefix

Michael Haggerty (22):
  t3600: clean up permissions test properly
  refs.h: clarify docstring for the ref_transaction_update()-related fns
  ref_iterator_begin_fn(): fix docstring
  prefix_ref_iterator: don't trim too much
  refs_ref_iterator_begin(): don't check prefixes redundantly
  refs: use `size_t` indexes when iterating over ref transaction updates
  ref_store: take `logmsg` parameter when deleting references
  lockfile: add a new method, is_lock_file_locked()
  files-backend: move `lock` member to `files_ref_store`
  files_ref_store: put the packed files lock directly in this struct
  files_transaction_cleanup(): new helper function
  ref_transaction_commit(): break into multiple functions
  ref_update_reject_duplicates(): expose function to whole refs module
  ref_update_reject_duplicates(): use `size_t` rather than `int`
  ref_update_reject_duplicates(): add a sanity check
  should_pack_ref(): new function, extracted from `files_pack_refs()`
  get_packed_ref_cache(): assume "packed-refs" won't change while locked
  read_packed_refs(): do more of the work of reading packed refs
  read_packed_refs(): report unexpected fopen() failures
  refs_ref_iterator_begin(): handle `GIT_REF_PARANOIA`
  create_ref_entry(): remove `check_name` option
  cache_ref_iterator_begin(): avoid priming unneeded directories

 builtin/fetch.c                |   2 +-
 builtin/remote.c               |   4 +-
 lockfile.h                     |   8 ++
 ref-filter.c                   |  62 ++++++++-
 refs.c                         |  83 ++++++++++--
 refs.h                         |  62 ++++++++-
 refs/files-backend.c           | 300 +++++++++++++++++++++++++----------------
 refs/iterator.c                |  14 +-
 refs/ref-cache.c               |  99 +++++++++++---
 refs/ref-cache.h               |   6 +-
 refs/refs-internal.h           |  56 ++++++--
 t/helper/test-ref-store.c      |   3 +-
 t/t1405-main-ref-store.sh      |   2 +-
 t/t1406-submodule-ref-store.sh |   2 +-
 t/t3600-rm.sh                  |   4 +-
 15 files changed, 538 insertions(+), 169 deletions(-)

-- 
2.11.0


             reply	other threads:[~2017-05-17 12:06 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17 12:05 Michael Haggerty [this message]
2017-05-17 12:05 ` [PATCH 01/23] t3600: clean up permissions test properly Michael Haggerty
2017-05-17 12:42   ` Jeff King
2017-05-17 14:01     ` Michael Haggerty
2017-05-18  4:10   ` Junio C Hamano
2017-05-19  3:37     ` Michael Haggerty
2017-05-17 12:05 ` [PATCH 02/23] refs.h: clarify docstring for the ref_transaction_update()-related fns Michael Haggerty
2017-05-17 16:46   ` Stefan Beller
2017-05-18  4:13     ` Junio C Hamano
2017-05-17 12:05 ` [PATCH 03/23] ref_iterator_begin_fn(): fix docstring Michael Haggerty
2017-05-17 12:05 ` [PATCH 04/23] prefix_ref_iterator: don't trim too much Michael Haggerty
2017-05-17 12:55   ` Jeff King
2017-05-17 14:11     ` Michael Haggerty
2017-05-17 14:22       ` Jeff King
2017-05-18  4:19   ` Junio C Hamano
2017-05-18  4:50     ` Michael Haggerty
2017-05-17 12:05 ` [PATCH 05/23] refs_ref_iterator_begin(): don't check prefixes redundantly Michael Haggerty
2017-05-17 12:59   ` Jeff King
2017-05-17 14:21     ` Michael Haggerty
2017-05-17 12:05 ` [PATCH 06/23] refs: use `size_t` indexes when iterating over ref transaction updates Michael Haggerty
2017-05-17 16:59   ` Stefan Beller
2017-05-18  4:55     ` Michael Haggerty
2017-05-17 12:05 ` [PATCH 07/23] ref_store: take `logmsg` parameter when deleting references Michael Haggerty
2017-05-17 13:12   ` Jeff King
2017-05-17 15:01     ` Michael Haggerty
2017-05-17 15:03       ` Jeff King
2017-05-17 12:05 ` [PATCH 08/23] lockfile: add a new method, is_lock_file_locked() Michael Haggerty
2017-05-17 13:12   ` Jeff King
2017-05-17 12:05 ` [PATCH 09/23] files-backend: move `lock` member to `files_ref_store` Michael Haggerty
2017-05-17 13:15   ` Jeff King
2017-05-17 15:49     ` Michael Haggerty
2017-05-17 12:05 ` [PATCH 10/23] files_ref_store: put the packed files lock directly in this struct Michael Haggerty
2017-05-17 13:17   ` Jeff King
2017-05-17 15:05     ` Michael Haggerty
2017-05-17 17:18     ` Stefan Beller
2017-05-18  0:18       ` Brandon Williams
2017-05-19  4:00       ` Michael Haggerty
2017-05-18  0:17     ` Brandon Williams
2017-05-18  1:11       ` Jeff King
2017-05-18 15:42         ` Brandon Williams
2017-05-17 12:05 ` [PATCH 11/23] files_transaction_cleanup(): new helper function Michael Haggerty
2017-05-17 13:19   ` Jeff King
2017-05-19  4:49     ` Michael Haggerty
2017-05-17 17:26   ` Stefan Beller
2017-05-19  4:42     ` Michael Haggerty
2017-05-17 12:05 ` [PATCH 12/23] ref_transaction_commit(): break into multiple functions Michael Haggerty
2017-05-17 17:44   ` Stefan Beller
2017-05-19  7:58     ` Michael Haggerty
2017-05-17 12:05 ` [PATCH 13/23] ref_update_reject_duplicates(): expose function to whole refs module Michael Haggerty
2017-05-17 12:05 ` [PATCH 14/23] ref_update_reject_duplicates(): use `size_t` rather than `int` Michael Haggerty
2017-05-17 12:05 ` [PATCH 15/23] ref_update_reject_duplicates(): add a sanity check Michael Haggerty
2017-05-17 12:05 ` [PATCH 16/23] should_pack_ref(): new function, extracted from `files_pack_refs()` Michael Haggerty
2017-05-17 12:05 ` [PATCH 17/23] get_packed_ref_cache(): assume "packed-refs" won't change while locked Michael Haggerty
2017-05-17 17:57   ` Stefan Beller
2017-05-18  1:15     ` Jeff King
2017-05-18 16:58       ` Stefan Beller
2017-05-17 12:05 ` [PATCH 18/23] read_packed_refs(): do more of the work of reading packed refs Michael Haggerty
2017-05-17 12:05 ` [PATCH 19/23] read_packed_refs(): report unexpected fopen() failures Michael Haggerty
2017-05-17 13:28   ` Jeff King
2017-05-17 15:27     ` Michael Haggerty
2017-05-18  4:57     ` Junio C Hamano
2017-05-18  5:08       ` Jeff King
2017-05-17 12:05 ` [PATCH 20/23] refs_ref_iterator_begin(): handle `GIT_REF_PARANOIA` Michael Haggerty
2017-05-17 13:29   ` Jeff King
2017-05-17 12:05 ` [PATCH 21/23] create_ref_entry(): remove `check_name` option Michael Haggerty
2017-05-17 12:05 ` [PATCH 22/23] ref-filter: limit traversal to prefix Michael Haggerty
2017-05-17 13:38   ` Jeff King
2017-05-19 10:02     ` Michael Haggerty
2017-05-17 12:05 ` [PATCH 23/23] cache_ref_iterator_begin(): avoid priming unneeded directories Michael Haggerty
2017-05-17 13:42 ` [PATCH 00/23] Prepare to separate out a packed_ref_store Jeff King
2017-05-17 18:14   ` Stefan Beller
2017-05-18 17:14 ` Johannes Sixt
2017-05-18 17:22   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1495014840.git.mhagger@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=novalis@novalis.org \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).