[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Deterministic hashing for lua tables
- From: Tony Finch <dot@...>
- Date: Fri, 16 Dec 2011 16:43:05 +0000
hollyrosella@hushmail.com <hollyrosella@hushmail.com> wrote:
> I am imagining changing ltable.c:hashpointer to a function which when
> called with a pointer p, looks p up in an internal hash table IHT. If p
> is already a key in IHT, the new hashpointer function would return the
> value there, and if not, it would
>
> 1) generate a hash value h from a deterministic series (just some
> PRNG with a fixed seed, which does not refer to p at all),
>
> 2) store the (p, h) pair in IHT, and
>
> 3) return h.
>
> Thus, as long there is a fixed order in which objects are assigned as
> keys to a Lua table T (which should happen if execution is
> deterministic), the hash values used to store them in T will be fully
> determined by the PRNG, and hence fully deterministic.
>
> Does this sound workable? I welcome any comments or criticism.
Sounds quite plausible. Another option might be to eagerly store the PRNG
value in the object itself.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
Trafalgar: Southwesterly veering northwesterly 5 or 6, occasionally 7 in
north. Rough or very rough. Rain or showers. Moderate or good.