|Just another Perl shrine|
Re: Re: Re: Hash Clash on purposeby BrowserUk (Pope)
|on Jun 03, 2003 at 17:58 UTC||Need Help??|
Agreed. My pseudo-code wasn't up to much.
However, I just remembered/re-discovered an interesting thing. In common with CV's, SV's and AV's, the HV structure has an NVX field. This is the 32-bit field used by SV's to store the numeric value of SV's once they have used in a numeric context. In the HV, it is unused.
It seems to me that this would be the perfect place to store a (hash) creation time generated random value that could be used to initialise the hash function.
That would effectively allow for a different hashing function for every hash within a program, and for every run, with no extra space required, and only hits would be:
The only real argument against the idea that I forsee is that it might be possible that an application could randomly hit worse case performance. Statistically, the odds of this happening are, I think much the same as now for any given dataset, but the possibility that an application that loaded that same hash with the same data every run, could randomly have that hash degenerate to worst case, could be seen as a problem.
I really wish I was set up to be able to build, test and propose this fix to p5p, but I'm not, and am unlikely to be in the near future. Maybe Elian or somebody can pass the idea along if they think it has some merit.
Examine what is said, not who speaks."Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller