{"thread":{"id":"64755","subject":"[RFC] reftable: indexed_table_ref_iter inefficiency","startedAt":"2026-01-08T17:59:09Z","lastAt":"2026-01-08T17:59:09Z","messageCount":1,"participants":["Tsahi Elkayam"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"533299","messageId":"RoV3JLYR-DPkt0_9M-1fsR7tvqQOElF032Z_KOgiKKwksx2K-MBL1N7KsXUZXHBXKybxvpdBsGYEMux-xSCU-EhvhusqsbvhK8K6pMr-tFM=@protonmail.com","threadId":"64755","inReplyTo":null,"subject":"[RFC] reftable: indexed_table_ref_iter inefficiency","fromName":"Tsahi Elkayam","fromEmail":"tsahi.elkayam@protonmail.com","sentAt":"2026-01-08T17:58:47Z","receivedAt":"2026-01-08T17:59:09Z","isPatch":false,"sender":{"key":"tsahi.elkayam@protonmail.com","avatar":null},"body":"Hi,\n\nFollowing Patrick's review of my recent patch fixing undefined behavior\nin indexed_table_ref_iter_next(), I noticed the TODO comment points to\na larger issue with the obj table implementation.\n\nIf I understand the current workflow correctly:\n\n  reftable_table_refs_for_indexed()\n    -> seeks to obj record matching OID prefix\n    -> reads one obj record\n    -> passes offsets to indexed_table_ref_iter_new()\n\n  indexed_table_ref_iter_next()\n    -> for each offset, reads entire ref block\n    -> iterates all records in block\n    -> manually filters by OID comparison\n\nIt seems like the code reads only one obj record, iterates through all\nref records in each block, and relies on manual filtering instead of\nusing the index properly.\n\nI think the correct approach would be:\n\n  1. Seek to first obj record with desired OID prefix\n  2. For each obj record starting with that prefix:\n     a. For each offset in the obj record:\n        - Read the ref block at that offset\n        - Yield refs whose value/target_value matches the OID\n     b. Move to next obj record\n  3. Stop when obj record no longer matches prefix\n\nThis would require indexed_table_ref_iter to hold a reference to the\nobj iterator instead of just the offsets array, and advance through\nobj records as offsets are exhausted.\n\nIs this the right approach? I would like to help fix this, but I'm not\nvery familiar with the reftable internals yet.\n\nThanks,\nTsahi\n"}]}