-
Notifications
You must be signed in to change notification settings - Fork 364
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
Cache Flow modification message in Antrea Agent #4495
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4495 +/- ##
==========================================
- Coverage 68.31% 67.87% -0.45%
==========================================
Files 400 403 +3
Lines 58324 57690 -634
==========================================
- Hits 39843 39155 -688
- Misses 15708 15823 +115
+ Partials 2773 2712 -61
|
0933bdb
to
3204cfd
Compare
3204cfd
to
7740f91
Compare
/test-all |
98c694c
to
f69a41f
Compare
/test-all |
/test-windows-all |
f69a41f
to
3459ed6
Compare
@@ -1046,6 +1116,10 @@ func preparePipelines() { | |||
} | |||
} | |||
pipelineMap[pipelineID] = generatePipeline(pipelineID, requiredTables) | |||
for _, obj := range tableCache.List() { |
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.
Why we need to add this?
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.
Set ofctrl.Table with a valid TableID to ensure the OpenFlow Modification messages can be generated successfully in tests. Since the TableID is used when generating OF messages, without this step, the test may be crashed. newFakeClient
is not suitable to mock client in the related cases.
3459ed6
to
92e6c1e
Compare
350b7ea
to
6ab2d29
Compare
6ab2d29
to
7cf875b
Compare
@wenyingd this is a large size change, could you add more details about it for reviewers to understand?
|
Updated in the commit message. |
pkg/agent/openflow/pipeline.go
Outdated
key string | ||
message ofctrl.OpenFlowModMessage | ||
table binding.Table | ||
isDropFlow bool |
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.
I reviewed the current usage of key, table, and isDropFlow. The first one seems only used by methods added for antctl, which can be easily changed to return flows directly instead. The latter two are used only by flowsToTrace
, which could actually get the same information from structs like conjunction or context. So perhaps we don't need to create this struct?
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.
For table
and isDropFlow
fields, I don't think it is a good idea to re-generate the flows from conjunction or context for flowsToTrace
which means consuming CPU calculation for the memory as the two fields are only two bytes per object in total. Instead, maybe I can get these information from the OpenFlowModMessage. Let me try to remove these two fields.
About key
field, I would like to use another patch to construct from the flow modification mesage because it may introduce more changes. What do you think @tnqn
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.
Removed the fields according to the offline discussion, and publish the functions to dynamically generate Flow string or match string from a FlowModification mesage. Could you review it again? @tnqn
cbbf692
to
ec409ec
Compare
ec409ec
to
7ecbdda
Compare
6809cd6
to
85a6be6
Compare
pkg/ovs/openflow/ofctrl_flow.go
Outdated
func (f *ofFlow) MatchString() string { | ||
repr := fmt.Sprintf("table=%d", f.table.id) | ||
if f.protocol != "" { | ||
repr = fmt.Sprintf("%s,%s", repr, f.protocol) | ||
} | ||
|
||
if len(f.matchers) > 0 { | ||
repr = fmt.Sprintf("%s,%s", repr, strings.Join(f.matchers, ",")) | ||
flowMod, err := f.getFlowMod() | ||
if err != nil { | ||
return "" | ||
} | ||
return repr | ||
return FlowModMatchString(flowMod) | ||
} |
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.
Got it, now I see the called functions are different
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.
Please add the description to the commit message as well for future reference
85a6be6
to
9898148
Compare
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.
Commit message is not formated properly. Follow the link in https://github.com/antrea-io/antrea/blob/main/CONTRIBUTING.md#getting-reviewers
9898148
to
b09854c
Compare
The commit message is not wrapped with the same length limit. I will re-format it when merging. Would suggest to automate the formatting (e.g. set your .vimrc) to avoid efforts spent on this. |
/test-all |
need rebase |
b09854c
to
13e3b5a
Compare
/test-all |
/test-ipv6-only-all |
The motivation for this patch is to reduce the memory used for storing the installed OpenFlow flow entries to replay them when OVS is re-connected. In the existing code, struct ofctrl.Flow is stored in the memory, which has taken a lot of memory because all kinds of the candidate Match fields are allocated in one such object although they may not use in the final Flow. This patch is to store the FlowModification message as a substituation of the ofctrl.Flow objects. As the FlowModification message is the obejct which was sent to OVS via the OF connections in final, it contains enough information to replay the OpenFlow flow entry. Besides, a FlowModification only contains the necessary fields which are set with values. A test with this patch may reduce about 140M memory on a setup with about 130K OpenFlow entries in antrea-agent (from 380M to 240M) Signed-off-by: wenyingd <[email protected]>
13e3b5a
to
23652ce
Compare
/test-all |
The motivation for this patch is to reduce the memory used for storing the installed OpenFlow flow entries to replay them when OVS is re-connected. In the existing code, struct ofctrl.Flow is stored in the memory, which has taken a lot of memory because all kinds of the candidate Match fields are allocated in one such object although they may not use in the final Flow. This patch is to store the FlowModification message as a substituation of the ofctrl.Flow objects. As the FlowModification message is the obejct which was sent to OVS via the OF connections in final, it contains enough information to replay the OpenFlow flow entry. Besides, a FlowModification only contains the necessary fields which are set with values. A test with this patch may reduce about 140M memory on a setup with about 130K OpenFlow entries in antrea-agent (from 380M to 240M) Signed-off-by: wenyingd <[email protected]>
he motivation for this patch is to reduce the memory used for storing the installed OpenFlow flow entries to replay them when OVS is re-connected. In the existing code, struct
ofctrl.Flow
is stored in the memory, which has taken a lot of memory because all kinds of the candidate Match fields are allocated in one such object although they may not use in the final Flow.This patch is to store the FlowModification message as a substituation of the
ofctrl.Flow
objects. As the FlowModification message is the obejct which was sent to OVS via the OF connections in final, it contains enough information to replay the OpenFlow flow entry. Besides, a FlowModification only contains the necessary fields which are set with values.A test with this patch may reduce about 140M memory on a setup with about 130K OpenFlow entries in antrea-agent (from 380M to 240M)
Signed-off-by: wenyingd [email protected]