Reduce the number of ifconfig calls made in add_topo#19119
Reduce the number of ifconfig calls made in add_topo#19119StormLiangMS merged 7 commits intosonic-net:masterfrom ccroy-arista:fix-excess-ifconfigs
Conversation
`ifconfig -a` is called for every VM in a topology within ansible/roles/vm_set/library/vm_topology.py. For topologies with a couple hundred VMs, this can take anywhere from seconds to minutes for each call to `ifconfig -a`. Multiplying this across the number of VMs results in these calls taking up the majority of time for add_topo to complete.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
The pre-commit check failed with: flake8...................................................................Failed
ansible/roles/vm_set/library/vm_topology.py:304:31: E201 whitespace after '[' @ccroy-arista can you help fix the issue? |
| # dualtor, hence why the former approach is preserved above for that case. | ||
| else: | ||
| # Get the intf information in a tabulated format. Discard the header row. | ||
| intf_rows = VMTopology.cmd('ifconfig -a -s').split('\n')[1:] |
There was a problem hiding this comment.
Can ip -j addr (JSON output of ip addr) be used? That way, manual string parsing isn't needed, and it also replaces one use of ifconfig with ip.
There was a problem hiding this comment.
Updated to use ip -j addr.
There was a problem hiding this comment.
@saiarcot895 I'm looking into using a sysfs approach with os.listdir, which should be an even more portable and general solution; I will provide an update once I have tested this approach, and if it works well then I'll update the PR as well.
There was a problem hiding this comment.
@saiarcot895 I've updated the changes to use the os.listdir approach now.
Fix formatting errors encountered during pre-commit check.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
hi @ccroy-arista , anything happened to this PR? |
|
Hi @r12f, I am updating this PR to a more portable and robust solution per: #19119 (comment) I will mark the PR active again once the change is updated. |
|
Ah, I see. Got it and no worries. Feel free to leave the PR in open state. It is just a regular "review-and-address-comment" cycles :D |
|
Thanks Riff, will do :) |
`ifconfig -a` is called for every VM in a topology within ansible/roles/vm_set/library/vm_topology.py. For topologies with a couple hundred VMs, this can take anywhere from seconds to minutes for each call to `ifconfig -a`. Multiplying this across the number of VMs results in these calls taking up the majority of time for add_topo to complete.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
hi @saiarcot895 would you help to review again for the update? |
|
hi @ccroy-arista could you check on the conflict to 202412? |
|
Manual cherry-pick to 202412 to resolve conflict: Azure/sonic-mgmt.msft#557 |
What is the motivation for this PR? To reduce the setup time for add_topo, particularly for topologies with a larger number of VMs. How did you do it? Reduced the number of ifconfig -a calls within VMTopology.init(...) from to 1. How did you verify/test it? Ran add_topo on a t1-isolated topology and confirmed that the setup time was reduced. Any platform specific information? This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations.
|
Cherry-pick PR to 202505: #19693 |
What is the motivation for this PR? To reduce the setup time for add_topo, particularly for topologies with a larger number of VMs. How did you do it? Reduced the number of ifconfig -a calls within VMTopology.init(...) from to 1. How did you verify/test it? Ran add_topo on a t1-isolated topology and confirmed that the setup time was reduced. Any platform specific information? This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations.
### Description of PR This is a manual cherry-pick of sonic-net/sonic-mgmt#19119 to 202412. Within `VMTopology.init`, `ifconfig -a` is called for every VM. For topologies with several hundred VMs, each call to `ifconfig -a` can take an appreciable amount of time (from seconds to minutes, depending on exact number of VMs and processing power of the testbed server). Multiplying this across hundreds of VMs results in `add_topo` taking a significant amount of time to complete. This change decreases the `add_topo` setup time by reducing the number of `ifconfig -a` calls within `VMTopology.init` from <number of VMs in the topology> to 1. This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations. Summary: Fixes # (issue) ### Type of change - [ ] Bug fix - [x] Testbed and Framework(new/improvement) - [ ] New Test case - [ ] Skipped for non-supported platforms - [ ] Test case improvement ### Back port request - [ ] 202205 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [x] 202412 ### Approach #### What is the motivation for this PR? To reduce the setup time for `add_topo`, particularly for topologies with a larger number of VMs. #### How did you do it? Reduced the number of `ifconfig -a` calls within `VMTopology.init(...)` from <number of VMs in the topology> to 1. #### How did you verify/test it? Ran `add_topo` on a t1-isolated topology and confirmed that the setup time was reduced. #### Any platform specific information? This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations.
What is the motivation for this PR? To reduce the setup time for add_topo, particularly for topologies with a larger number of VMs. How did you do it? Reduced the number of ifconfig -a calls within VMTopology.init(...) from to 1. How did you verify/test it? Ran add_topo on a t1-isolated topology and confirmed that the setup time was reduced. Any platform specific information? This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations. Signed-off-by: opcoder0 <110003254+opcoder0@users.noreply.github.com>
What is the motivation for this PR? To reduce the setup time for add_topo, particularly for topologies with a larger number of VMs. How did you do it? Reduced the number of ifconfig -a calls within VMTopology.init(...) from to 1. How did you verify/test it? Ran add_topo on a t1-isolated topology and confirmed that the setup time was reduced. Any platform specific information? This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations. Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
What is the motivation for this PR? To reduce the setup time for add_topo, particularly for topologies with a larger number of VMs. How did you do it? Reduced the number of ifconfig -a calls within VMTopology.init(...) from to 1. How did you verify/test it? Ran add_topo on a t1-isolated topology and confirmed that the setup time was reduced. Any platform specific information? This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations.
What is the motivation for this PR? To reduce the setup time for add_topo, particularly for topologies with a larger number of VMs. How did you do it? Reduced the number of ifconfig -a calls within VMTopology.init(...) from to 1. How did you verify/test it? Ran add_topo on a t1-isolated topology and confirmed that the setup time was reduced. Any platform specific information? This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations. Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
What is the motivation for this PR? To reduce the setup time for add_topo, particularly for topologies with a larger number of VMs. How did you do it? Reduced the number of ifconfig -a calls within VMTopology.init(...) from to 1. How did you verify/test it? Ran add_topo on a t1-isolated topology and confirmed that the setup time was reduced. Any platform specific information? This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations. Signed-off-by: Yael Tzur <ytzur@nvidia.com>
Description of PR
Within
VMTopology.init,ifconfig -ais called for every VM. For topologies with several hundred VMs, each call toifconfig -acan take an appreciable amount of time (from seconds to minutes, depending on exact number of VMs and processing power of the testbed server). Multiplying this across hundreds of VMs results inadd_topotaking a significant amount of time to complete.This change decreases the
add_toposetup time by reducing the number ofifconfig -acalls withinVMTopology.initfrom to 1.This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations.
Summary:
Fixes # (issue)
Type of change
Back port request
Approach
What is the motivation for this PR?
To reduce the setup time for
add_topo, particularly for topologies with a larger number of VMs.How did you do it?
Reduced the number of
ifconfig -acalls withinVMTopology.init(...)from to 1.How did you verify/test it?
Ran
add_topoon a t1-isolated topology and confirmed that the setup time was reduced.Any platform specific information?
This change reduces setup time for non-multi-DUT configurations only; it does not impact the setup time for multi-DUT configurations.