git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/3] refs/files: use heuristics to decide whether to repack with `--auto`

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 4, 2024, 08:52 UTC
Message-ID
<cover.1725439407.git.ps@pks.im>
In-Reply-To
<cover.1725280479.git.ps@pks.im>
Hi,

this is the second version of my patch series that introduces a new heuristic for packing refs with the "files" backend. This heuristic is designed to avoid needlessly rewriting the "packed-refs" file when there are only a small set of loose refs. The number of loose refs required scales with the size of the "packed-refs" file.

There is only one change compared to v1, namely a deduplication of the log2 functions we have in our tree.

Thanks!
Patrick
Patrick Steinhardt (3):
  wrapper: introduce `log2u()`
  t0601: merge tests for auto-packing of refs
  refs/files: use heuristic to decide whether to repack with `--auto`
 bisect.c                      |  12 +---
 refs/files-backend.c          |  65 ++++++++++++++++++++++
 refs/packed-backend.c         |  18 ++++++
 refs/packed-backend.h         |   7 +++
 t/t0601-reffiles-pack-refs.sh | 101 ++++++++++++++++++++++++++++------
 wrapper.h                     |  18 ++++++
 6 files changed, 194 insertions(+), 27 deletions(-)
Range-diff against v1:
-:  ----------- > 1:  df8c5dffffe wrapper: introduce `log2u()`
1:  3a8063e8b2c = 2:  4a59cec205d t0601: merge tests for auto-packing of refs
2:  9a63abfe3b8 ! 3:  49f953142b1 refs/files: use heuristic to decide whether to repack with `--auto`
    @@ refs/files-backend.c: static int should_pack_ref(struct files_ref_store *refs,
      	return 0;
      }
      
    -+static size_t fastlog2(size_t sz)
    -+{
    -+	size_t l = 0;
    -+	if (!sz)
    -+		return 0;
    -+	for (; sz; sz /= 2)
    -+		l++;
    -+	return l - 1;
    -+}
    -+
     +static int should_pack_refs(struct files_ref_store *refs,
     +			    struct pack_refs_opts *opts)
     +{
    @@ refs/files-backend.c: static int should_pack_ref(struct files_ref_store *refs,
     +	 * packed refs. This heuristic may be tweaked in the future, but should
     +	 * serve as a sufficiently good first iteration.
     +	 */
    -+	limit = fastlog2(packed_size / 100) * 5;
    ++	limit = log2u(packed_size / 100) * 5;
     +	if (limit < 16)
     +		limit = 16;
     +
base-commit: 4590f2e9412378c61eac95966709c78766d326ba
-- 
2.46.0.519.g2e7b89e038.dirty
Previous: karthik nayakNext: Patrick Steinhardt
Message 11 of 16 in “refs/files: use heuristic to decide whether to repack with `--auto`”
  1. 0/2 refs/files: use heuristic to decide whether to repack with `--auto`Patrick Steinhardt, Sep 2, 2024
  2. 1/2 t0601: merge tests for auto-packing of refsPatrick Steinhardt, Sep 2, 2024
  3. 2/2 refs/files: use heuristic to decide whether to repack with `--auto`Patrick Steinhardt, Sep 2, 2024
  4. karthik nayakSep 3, 2024
  5. Patrick SteinhardtSep 3, 2024
  6. Junio C HamanoSep 3, 2024
  7. Patrick SteinhardtSep 4, 2024
  8. Junio C HamanoSep 4, 2024
  9. Patrick SteinhardtSep 4, 2024
  10. karthik nayakSep 5, 2024
  11. 0/3 refs/files: use heuristics to decide whether to repack with `--auto`Patrick Steinhardt, Sep 4, 2024
  12. 1/3 wrapper: introduce `log2u()`Patrick Steinhardt, Sep 4, 2024
  13. 2/3 t0601: merge tests for auto-packing of refsPatrick Steinhardt, Sep 4, 2024
  14. 3/3 refs/files: use heuristic to decide whether to repack with `--auto`Patrick Steinhardt, Sep 4, 2024
  15. Junio C HamanoSep 4, 2024
  16. Patrick SteinhardtSep 5, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.