You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 - 1 unused, 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/fnc function for hashing which increases the range to the full capacity of 3 to 2^32 - 1, thus reducing the probability of a collision near zero (not zero however). Moreover, due to the hash/fnv function, the anagram problem is solved, as, unlike ASCII addition, the hash/fnv function 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.go file to account for the new 32 bit addresses.
Automated Unit Tests: Updated TestIdToGuestCID in pkg/unikontainers/vaccel_test.go to 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.
Manual E2E Testing:
Executed a vaccel-enabled container image, explicitly passing the required annotations to trigger vsock initialization:
Verified that the QEMU CLI execution accurately reflected the high-entropy CID (32 bit uint): -device vhost-vsock-pci, id=vhost-vsock-pci0,guest-cid=688968749.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).