refs/packed-backend.c: add trace2 counters for jump list

The previous commit added low-level tests to ensure that the packed-refs
iterator did not enumerate excluded sections of the refspace.

However, there was no guarantee that these sections weren't being
visited, only that they were being suppressed from the output. To harden
these tests, add a trace2 counter which tracks the number of regions
skipped by the packed-refs iterator, and assert on its value.

Suggested-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Taylor Blau
2023-07-10 17:12:31 -04:00
committed by Junio C Hamano
parent 59c35fac54
commit c489f47a64
4 changed files with 49 additions and 19 deletions

View File

@ -12,6 +12,7 @@
#include "../chdir-notify.h"
#include "../wrapper.h"
#include "../write-or-die.h"
#include "../trace2.h"
enum mmap_strategy {
/*
@ -845,6 +846,7 @@ static int next_record(struct packed_ref_iterator *iter)
iter->jump_cur++;
if (iter->pos < curr->end) {
iter->pos = curr->end;
trace2_counter_add(TRACE2_COUNTER_ID_PACKED_REFS_JUMPS, 1);
/* jumps are coalesced, so only one jump is necessary */
break;
}