-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weighted Random Policy #327
Conversation
@twood02 we allocate and free lb->weights and lb->policy using standard malloc and free functions. However, in the previous of the code dpdk's function rte_calloc and rte_free are used. Should I edit this code to use those functions? I am not sure how to free them later in that case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start! I've marked a few things which can be improved.
|
||
/* structures to store server weights */ | ||
int *weights; | ||
int total_weight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your data structure here will allow us to represent weighted load balancers, but there could be other policies we could come up with in the future that might need totally different data. For now this is fine, but you should think about how you would make this data structure generic so it works for all LBs (but still allows customization by each policy in some way)
The main differences between normal malloc and rte_malloc are:
For your use case, you are allocating memory which will only be used by the LB NF and you are only doing it once when the NF starts. So it is fine to use normal malloc here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit more cleanup then this is ready
@twood02 I removed the commented code and did a final check with all policies. this should be good to go |
@xwedea - can you put a description of what this PR adds at the top of this page. When we make our release notes for each ONVM version we go back to the PRs to get short descriptions of each new feature. Otherwise this looks good and I will merge it into develop. Then next week we'll go through a full review process with @andreaseno's PR where he will run the NFs and demonstrate it working for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
The only issue is that it requires all config files to have weights specified even if they aren't used, but this will be resolved by PR #328 that changes to using JSON config files.
@twood02 I put a description. |
This PR adds 2 new policies to the load balancer: Random and Weighted Random.
After this PR, there are 3 policies that can be specified in the configuration file as:
Summary:
Usage:
Merging notes:
TODO before merging :
Test Plan:
Review:
(optional) << @-mention people who should review these changes >>
(optional) Subscribers: << @-mention people who probably care about these changes >>