fix[vAccel]: optimized hash function in idToGuestCID to reduce collisions - #895
fix[vAccel]: optimized hash function in idToGuestCID to reduce collisions#895Cicada1107 wants to merge 2 commits into
Conversation
Signed-off-by: Arijit Dubey <arijitdubey2018@gmail.com>
Signed-off-by: Arijit Dubey <arijitdubey2018@gmail.com>
✅ Deploy Preview for urunc canceled.
|
|
This still doesn't eliminate the possibility of collisions. I think we'd need some sort of map/table. I initially thought of uuid but that's 128bits |
|
Hello @Nachiket-Roy , yes, this doesn't eliminate the possibility of collisions completely. However, as was discussed in the community call, the current approach is sub optimal for no apparent reason and leaves a lot of unused space on the table. As discussed, this PR's role is to utilize that space and decrease the collision rate significantly, for the time being, for as long as we don't have a Deterministic non-collision solution, and to replace the currently redundant algorithm for now. As for non-collision solutions, any approach that I can think of that would completely eliminate collisions, would have to rely on Kernel Level probing, which is probably not a good choice for urunc. |
Description
Currently the vsock CID for the guest unikontainers spawned with vAccel are restricted to the range 3 to 99, leaving the actually permitted ceiling space of
2^32 - 1unused, thus introducing redundancy. This is a very small range and thus the probability of a collision is very high. Moreover, the hash function used (ASCII Summation + Modulo Arithmetic) does not account for anagrams.This PR optimizes this redundancy by replacing with the standard
hash/fncfunction for hashing which increases the range to the full capacity of3to2^32 - 1, thus reducing the probability of a collision near zero (not zero however). Moreover, due to thehash/fnvfunction, the anagram problem is solved, as, unlike ASCII addition, thehash/fnvfunction depends on the direction of traversal as well; thus, Anagramic addresses would result in completely different hashes and thus collision would be avoided.Also, this PR modifies the
vAcccel_test.gofile to account for the new 32 bit addresses.Related issues
idToGuestCIDgenerates frequent vsock CID collisions due to limited output space #688How was this tested?
pkg/unikontainers/vaccel_test.goto assert against the new 32-bit hashes. Also added a specific test using the exact anagram IDs ("abcdef0123456789" * 4 vs "9876543210fedcba" * 4). All tests passed.(Debug level set to 4 in env variables)
-device vhost-vsock-pci, id=vhost-vsock-pci0,guest-cid=688968749.LLM usage
Gemini 3.1 Pro
Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).