From: Ezekiel Newren Date: Fri, 14 Nov 2025 05:41:15 GMT Subject: Re: [PATCH v3 06/10] xdiff: split xrecord_t.ha into line_hash and minimal_perfect_hash Message-ID: In-Reply-To: On Tue, Nov 11, 2025 at 4:21 PM Junio C Hamano wrote: > > "Ezekiel Newren via GitGitGadget" writes: > > > To make this clearer, the old ha field has been split: > > * line_hash: a straightforward hash of a line, independent of any > > external context. Its type is uint64_t, as it comes from a fixed > > width hash function. > > * minimal_perfect_hash: Not a new concept, but now a separate > > field. It comes from the classifier's general-purpose hash table, > > which assigns each line a unique and minimal hash across the two > > files. A size_t is used here because it's meant to be used to > > index an array. This also this avoids ` as usize` casts on the Rust > > side when using it to index a slice. > > How much extra memory pressure does this change cause? In a single > instance of xrecord_t, we used to have a single ulong plus a pointer > and a size_t; now we replaced the single ulong with two 8-byte words, > so 33% more memory per record, which is not so huge a deal? This was asked and answered earlier in this patch series [1]. > > static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec) { > > - long hi; > > + size_t hi; > > xdlclass_t *rcrec; > > > > - hi = (long) XDL_HASHLONG(rec->ha, cf->hbits); > > + hi = XDL_HASHLONG(rec->line_hash, cf->hbits); > > Very nice that we can lose these random-looking casts. This was Phillip's suggestion [2]. Thanks Phillip. [1] https://lore.kernel.org/git/CAH=ZcbD7FeRHtYvN_4=qHApB-AwK18=KRU2SGWNg8ADkrFM-Fw@mail.gmail.com/ [2] https://lore.kernel.org/git/a66fb440-058e-4cd8-8971-9c320c0387e8@gmail.com/