From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, derrickstolee@github.com, peff@peff.net
Subject: [PATCH v2 3/3] midx.c: unify `include_pack` array into `pack_info` struct
Date: Tue, 20 Sep 2022 16:40:22 -0400 [thread overview]
Message-ID: <81e9ccc3232f1a372adc9b06e2a93e9d9b26c80d.1663706401.git.me@ttaylorr.com> (raw)
In-Reply-To: <cover.1663706401.git.me@ttaylorr.com>
The MIDX repack code uses a separate byte-array to track which packs are
"included" in the rollup. Now that an array of `repack_info` structs is
available for the lifetime of the `midx_repack()` function, we can
instead use a new bit in that struct's record instead of maintaining a
separate array.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
midx.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/midx.c b/midx.c
index 5fbf964bba..59db9162ea 100644
--- a/midx.c
+++ b/midx.c
@@ -1865,6 +1865,7 @@ struct repack_info {
timestamp_t mtime;
uint32_t referenced_objects;
uint32_t pack_int_id;
+ unsigned include : 1;
};
static int compare_by_mtime(const void *a_, const void *b_)
@@ -1883,7 +1884,7 @@ static int compare_by_mtime(const void *a_, const void *b_)
static int fill_included_packs_all(struct repository *r,
struct multi_pack_index *m,
- unsigned char *include_pack)
+ struct repack_info *pack_info)
{
uint32_t i, count = 0;
int pack_kept_objects = 0;
@@ -1896,7 +1897,7 @@ static int fill_included_packs_all(struct repository *r,
if (!pack_kept_objects && m->packs[i]->pack_keep)
continue;
- include_pack[i] = 1;
+ pack_info[i].include = 1;
count++;
}
@@ -1906,7 +1907,6 @@ static int fill_included_packs_all(struct repository *r,
static int fill_included_packs_batch(struct repository *r,
struct multi_pack_index *m,
struct repack_info *pack_info,
- unsigned char *include_pack,
size_t batch_size)
{
uint32_t i, packs_to_repack;
@@ -1918,8 +1918,8 @@ static int fill_included_packs_batch(struct repository *r,
total_size = 0;
packs_to_repack = 0;
for (i = 0; total_size < batch_size && i < m->num_packs; i++) {
- int pack_int_id = pack_info[i].pack_int_id;
- struct packed_git *p = m->packs[pack_int_id];
+ struct repack_info *info = &pack_info[i];
+ struct packed_git *p = m->packs[info->pack_int_id];
size_t expected_size;
if (!p)
@@ -1938,7 +1938,8 @@ static int fill_included_packs_batch(struct repository *r,
packs_to_repack++;
total_size += expected_size;
- include_pack[pack_int_id] = 1;
+
+ info->include = 1;
}
if (packs_to_repack < 2)
@@ -1951,7 +1952,6 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
{
int result = 0;
uint32_t i;
- unsigned char *include_pack;
struct child_process cmd = CHILD_PROCESS_INIT;
FILE *cmd_in;
struct strbuf base_name = STRBUF_INIT;
@@ -1970,7 +1970,6 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
if (!m)
return 0;
- CALLOC_ARRAY(include_pack, m->num_packs);
CALLOC_ARRAY(pack_info, m->num_packs);
for (i = 0; i < m->num_packs; i++) {
@@ -1988,10 +1987,9 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
QSORT(pack_info, m->num_packs, compare_by_mtime);
if (batch_size) {
- if (fill_included_packs_batch(r, m, pack_info, include_pack,
- batch_size))
+ if (fill_included_packs_batch(r, m, pack_info, batch_size))
goto cleanup;
- } else if (fill_included_packs_all(r, m, include_pack))
+ } else if (fill_included_packs_all(r, m, pack_info))
goto cleanup;
repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset);
@@ -2035,7 +2033,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
strbuf_strip_suffix(&scratch, ".idx");
strbuf_addstr(&scratch, ".pack");
- fprintf(cmd_in, "%s%s\n", include_pack[info->pack_int_id] ? "" : "^", scratch.buf);
+ fprintf(cmd_in, "%s%s\n", info->include ? "" : "^", scratch.buf);
}
fclose(cmd_in);
strbuf_release(&scratch);
@@ -2050,6 +2048,5 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
cleanup:
free(pack_info);
- free(include_pack);
return result;
}
--
2.37.0.1.g1379af2e9d
next prev parent reply other threads:[~2022-09-20 20:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <YyokIf%2FSd7SYztKQ@nand.local>
2022-09-20 20:40 ` [PATCH v2 0/3] midx: use `--stdin-packs` to implement `repack` Taylor Blau
2022-09-20 20:40 ` [PATCH v2 1/3] midx.c: compute pack_info array outside of fill_included_packs_batch() Taylor Blau
2022-09-20 20:40 ` [PATCH v2 2/3] midx.c: use `pack-objects --stdin-packs` when repacking Taylor Blau
2022-09-23 18:23 ` Derrick Stolee
2022-09-23 18:28 ` Taylor Blau
2022-09-23 19:05 ` Derrick Stolee
2022-09-20 20:40 ` Taylor Blau [this message]
2022-09-20 21:54 ` [PATCH v2 0/3] midx: use `--stdin-packs` to implement `repack` Jeff King
2022-09-21 19:09 ` Junio C Hamano
2022-09-23 18:29 ` Taylor Blau
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=81e9ccc3232f1a372adc9b06e2a93e9d9b26c80d.1663706401.git.me@ttaylorr.com \
--to=me@ttaylorr.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).