[RFC] reftable: indexed_table_ref_iter inefficiency

From: Tsahi Elkayam <hidden>
Date: 2026-01-08 17:59:09

Hi,

Following Patrick's review of my recent patch fixing undefined behavior
in indexed_table_ref_iter_next(), I noticed the TODO comment points to
a larger issue with the obj table implementation.

If I understand the current workflow correctly:

  reftable_table_refs_for_indexed()
    -> seeks to obj record matching OID prefix
    -> reads one obj record
    -> passes offsets to indexed_table_ref_iter_new()

  indexed_table_ref_iter_next()
    -> for each offset, reads entire ref block
    -> iterates all records in block
    -> manually filters by OID comparison

It seems like the code reads only one obj record, iterates through all
ref records in each block, and relies on manual filtering instead of
using the index properly.

I think the correct approach would be:

  1. Seek to first obj record with desired OID prefix
  2. For each obj record starting with that prefix:
     a. For each offset in the obj record:
        - Read the ref block at that offset
        - Yield refs whose value/target_value matches the OID
     b. Move to next obj record
  3. Stop when obj record no longer matches prefix

This would require indexed_table_ref_iter to hold a reference to the
obj iterator instead of just the offsets array, and advance through
obj records as offsets are exhausted.

Is this the right approach? I would like to help fix this, but I'm not
very familiar with the reftable internals yet.

Thanks,
Tsahi
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help