feat(agent): proper label/mode based delegation #89
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.
When locating agents for tx cannon compute or nodes within an env, the control plane will attempt to fulfill a request for agents of specific labels.
To solve the challenge of doing set difference in bulk, the
fixedbitset
crate is being used to convert labels and modes into a mask, and then that mask can be compared performantly using SIMD instructions (rather than iterating the sets many many times).The delegation algorithm is as follows:
Example
topology is requesting 3 nodes with different labels:
alpha
bravo
charlie
the available agents are:
alpha, bravo
, with modes validator, clientalpha, bravo
, with modes validatorcharlie
, with modes client, proverA bitmask will be created with each bit being in a different pair of brackets:
[validator][prover][client][compute][alpha][bravo][charlie]
The nodes and agents will be converted into the following masks:
1000100
1000010
0010001
1010110
1000110
0110001
The node's masks can then be compared in parallel to check if they are a subset of the agent's masks, and if a match is detected, the agent can be atomically selected to be used in the environment.