git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 04/16] reftable/block: simplify how we track restart points
Date: Mon, 7 Apr 2025 14:31:07 +0200	[thread overview]
Message-ID: <Z_PFi4-B3ACD5hmq@pks.im> (raw)
In-Reply-To: <CAOLa=ZRwRkV56HAxtfX3EM1Lr3D938bY7d-zv+xUF4G40f-O2A@mail.gmail.com>

On Thu, Apr 03, 2025 at 08:17:50AM -0700, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > Restart points record the location of reftable records that do not use
> > prefix compression and are used to perform a binary search inside of a
> > block. These restart points are encoded at the end of a block, between
> > the record data and the footer of a table.
> >
> > The block structure contains three different variables related to these
> > restart points:
> >
> >   - The block length contains the length of the reftable block up to the
> >     restart points.
> >
> >   - The restart count contains the number of restart points contained in
> >     the block.
> >
> >   - The restart bytes variable tracks where the restart point data
> >     begins.
> >
> > Tracking all three of these variables is unnecessary though as the data
> > can be derived from one another: the block length without restart points
> > is the exact same as the offset of the restart count data, which we
> > already track via the `restart_bytes` data.
> >
> 
> Nit: This para makes it seem as if we'd eliminate 'block length' in
> support of having/keeping `restart_bytes`, but we remove both.

We don't, we only remove the block length. The restart bytes are
retained, but they are renamed to `restart_off` to better reflect what
it actually contains. The next paragraph tries to explain this:

> > Refactor the code so that we track the location of restart bytes not as
> > a pointer, but instead as an offset. This allows us to trivially get rid
> > of the `block_len` variable as described above. This avoids having the
> > confusing `block_len` variable and allows us to do less bookkeeping
> > overall.
> >
> > Signed-off-by: Patrick Steinhardt <ps@pks.im>
> > ---
> >  reftable/block.c | 25 ++++++++++++-------------
> >  reftable/block.h |  8 +++++---
> >  reftable/table.c |  2 +-
> >  3 files changed, 18 insertions(+), 17 deletions(-)
> >
> > diff --git a/reftable/block.c b/reftable/block.c
> > index 97740187259..f2567a8f0fd 100644
> > --- a/reftable/block.c
> > +++ b/reftable/block.c
> > @@ -216,10 +216,9 @@ int block_reader_init(struct block_reader *br, struct reftable_block *block,
> >  	uint32_t full_block_size = table_block_size;
> >  	uint8_t typ = block->data[header_off];
> >  	uint32_t sz = reftable_get_be24(block->data + header_off + 1);
> > -	int err = 0;
> > -	uint16_t restart_count = 0;
> > -	uint32_t restart_start = 0;
> > -	uint8_t *restart_bytes = NULL;
> > +	uint16_t restart_count;
> > +	uint32_t restart_off;
> 
> Nit: I guess this is to be consistent with `header_off`, but I would
> think spelling it out as `header_offset` is much easier to understand.

Yeah, I'm not much of a fan of such abbreviations, either. But I'd like
to retain this abbreviation for the sake of consistency.

Patrick

  reply	other threads:[~2025-04-07 12:31 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31  8:41 [PATCH 00/16] reftable: overhaul the API to expose access to blocks Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 01/16] reftable: fix formatting of the license header Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 02/16] reftable/reader: rename data structure to "table" Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 03/16] reftable/blocksource: consolidate code into a single file Patrick Steinhardt
2025-04-02 17:42   ` Justin Tobler
2025-04-03 10:42   ` Karthik Nayak
2025-03-31  8:41 ` [PATCH 04/16] reftable/block: simplify how we track restart points Patrick Steinhardt
2025-04-02 18:08   ` Justin Tobler
2025-04-03 15:17   ` Karthik Nayak
2025-04-07 12:31     ` Patrick Steinhardt [this message]
2025-03-31  8:41 ` [PATCH 05/16] reftable/table: move reading block into block reader Patrick Steinhardt
2025-04-02 20:13   ` Justin Tobler
2025-04-07 12:31     ` Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 06/16] reftable/block: rename `block` to `block_data` Patrick Steinhardt
2025-04-02 20:26   ` Justin Tobler
2025-04-07 12:30     ` Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 07/16] reftable/block: rename `block_reader` to `reftable_block` Patrick Steinhardt
2025-04-02 20:39   ` Justin Tobler
2025-04-07 12:30     ` Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 08/16] git-zlib: use `struct z_stream_s` instead of typedef Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 09/16] reftable/block: create public interface for reading blocks Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 10/16] reftable/block: store block pointer in the block iterator Patrick Steinhardt
2025-04-02 20:56   ` Justin Tobler
2025-04-07 12:31     ` Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 11/16] reftable/block: make block iterators reseekable Patrick Steinhardt
2025-04-02 21:24   ` Justin Tobler
2025-04-07 12:30     ` Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 12/16] reftable/block: expose a generic iterator over reftable records Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 13/16] reftable/table: add `reftable_table` to the public interface Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 14/16] reftable/table: introduce iterator for table blocks Patrick Steinhardt
2025-04-01 22:08   ` Junio C Hamano
2025-04-02  7:21     ` Patrick Steinhardt
2025-04-02 21:46   ` Justin Tobler
2025-04-07 12:31     ` Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 15/16] reftable/constants: make block types part of the public interface Patrick Steinhardt
2025-03-31  8:41 ` [PATCH 16/16] reftable/table: move printing logic into test helper Patrick Steinhardt
2025-04-02 21:52   ` Justin Tobler
2025-04-07 13:16 ` [PATCH v2 00/16] reftable: overhaul the API to expose access to blocks Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 01/16] reftable: fix formatting of the license header Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 02/16] reftable/reader: rename data structure to "table" Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 03/16] reftable/blocksource: consolidate code into a single file Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 04/16] reftable/block: simplify how we track restart points Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 05/16] reftable/table: move reading block into block reader Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 06/16] reftable/block: rename `block` to `block_data` Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 07/16] reftable/block: rename `block_reader` to `reftable_block` Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 08/16] git-zlib: use `struct z_stream_s` instead of typedef Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 09/16] reftable/block: create public interface for reading blocks Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 10/16] reftable/block: store block pointer in the block iterator Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 11/16] reftable/block: make block iterators reseekable Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 12/16] reftable/block: expose a generic iterator over reftable records Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 13/16] reftable/table: add `reftable_table` to the public interface Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 14/16] reftable/table: introduce iterator for table blocks Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 15/16] reftable/constants: make block types part of the public interface Patrick Steinhardt
2025-04-07 13:16   ` [PATCH v2 16/16] reftable/table: move printing logic into test helper Patrick Steinhardt
2025-04-14 19:42   ` [PATCH v2 00/16] reftable: overhaul the API to expose access to blocks Justin Tobler

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=Z_PFi4-B3ACD5hmq@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --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).