git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: karthik nayak <karthik.188@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 0/3] refs/files: use heuristics to decide whether to repack with `--auto`
Date: Wed, 4 Sep 2024 10:52:58 +0200	[thread overview]
Message-ID: <cover.1725439407.git.ps@pks.im> (raw)
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


  parent reply	other threads:[~2024-09-04  8:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-02 13:48 [PATCH 0/2] refs/files: use heuristic to decide whether to repack with `--auto` Patrick Steinhardt
2024-09-02 13:48 ` [PATCH 1/2] t0601: merge tests for auto-packing of refs Patrick Steinhardt
2024-09-02 13:48 ` [PATCH 2/2] refs/files: use heuristic to decide whether to repack with `--auto` Patrick Steinhardt
2024-09-03  9:00   ` karthik nayak
2024-09-03  9:23     ` Patrick Steinhardt
2024-09-03 18:23       ` Junio C Hamano
2024-09-04  7:42         ` Patrick Steinhardt
2024-09-04 16:15           ` Junio C Hamano
2024-09-04  8:49     ` Patrick Steinhardt
2024-09-05  8:44       ` karthik nayak
2024-09-04  8:52 ` Patrick Steinhardt [this message]
2024-09-04  8:53   ` [PATCH v2 1/3] wrapper: introduce `log2u()` Patrick Steinhardt
2024-09-04  8:53   ` [PATCH v2 2/3] t0601: merge tests for auto-packing of refs Patrick Steinhardt
2024-09-04  8:53   ` [PATCH v2 3/3] refs/files: use heuristic to decide whether to repack with `--auto` Patrick Steinhardt
2024-09-04 15:24     ` Junio C Hamano
2024-09-05  9:58       ` Patrick Steinhardt

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

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

  git send-email \
    --in-reply-to=cover.1725439407.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@gmail.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.
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 NNTP newsgroup(s).