EfficientHashing Mod 1.18–26.1.2
MODEfficientHashing modifies the hashing algorithm for BlockPos and its subclasses, replacing the vanilla algorithm with PhiMix. The purpose of this change is to improve collision resistance, leading to performance improvements where BlockPos hashcodes are utilized. A test demonstrated that the vanilla algorithm produced 194,571 unique hashcodes from over 2,800,000 BlockPos objects, resulting in a 93.2% collision rate. In contrast, EfficientHashing's PhiMix algorithm generated 2,868,471 unique hashcodes for the same dataset, achieving a 0% collision rate.
EfficientHashing modifies the hashing algorithm for BlockPos and its subclasses, replacing the vanilla algorithm with PhiMix. The purpose of this change is to improve collision resistance, leading to performance improvements where BlockPos hashcodes are utilized. A test demonstrated that the vanilla algorithm produced 194,571 unique hashcodes from over 2,800,000 BlockPos objects, resulting in a 93.2% collision rate. In contrast, EfficientHashing's PhiMix algorithm generated 2,868,471 unique hashcodes for the same dataset, achieving a 0% collision rate.
PhiMix is approximately 95.3% the performance of the original hashing algorithm, indicating it is slightly slower. However, this performance difference is considered small when weighed against the significant enhancement in hash collision resistance. EfficientHashing maintains compatibility with vanilla behavior by ensuring that hashing the "default" instance of BlockPos, BlockPos.ORIGIN, still produces a hashcode of 0, mirroring the vanilla integer default.
