[device-data] Replace bash HwSKU loop with Python for ~200x speedup#25704
Open
rustiqly wants to merge 1 commit intosonic-net:masterfrom
Open
[device-data] Replace bash HwSKU loop with Python for ~200x speedup#25704rustiqly wants to merge 1 commit intosonic-net:masterfrom
rustiqly wants to merge 1 commit intosonic-net:masterfrom
Conversation
The sonic-device-data build generates VS HwSKU mappings (lanemap.ini, coreportindexmap.ini, SAI profiles) for all ~470 hardware SKUs. The existing bash implementation uses a while-read loop with per-line awk calls, taking ~9 minutes on a 24-core build machine. Replace the bash loop with a Python script (generate_vs_hwsku.py) that: - Processes all HwSKUs in <1 second (vs ~9 minutes) - Handles all the same cases: chassis configs, multi-ASIC subdirs, profile copying, context_config.json cleanup - Produces byte-identical output to the bash version The rest of the Makefile (device copy, mellanox simx, dpkg-buildpackage) is unchanged. This is a pure refactor with no functional changes. Signed-off-by: Rustiqly <[email protected]>
c289b3d to
35850a8
Compare
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What I did
Replaced the ~100-line bash while-read loop in
src/sonic-device-data/Makefilewith a Python script (generate_vs_hwsku.py) that generates VS HwSKU data ~200x faster.Why I did it
The sonic-device-data package build generates VS HwSKU mappings (lanemap.ini, coreportindexmap.ini, SAI profiles) for all ~470 hardware SKUs. The existing bash implementation uses a
while IFS= read -r lineloop with per-lineawkcalls andgreppattern matching. On a 24-core build machine, this takes ~9 minutes — significant when the full VS build is ~50 minutes.The Python replacement processes all 477 HwSKUs in <1 second.
How I did it
src/sonic-device-data/src/generate_vs_hwsku.py— handles all cases: chassis configs with midplane reservation, multi-ASIC subdirectories (0/1/2), profile copying, context_config.json cleanupBugfix included
The bash loop had a minor bug: empty lines in
port_config.ini(common in files with license headers) were not skipped by thegrep -q "^#"check, creating lanemap entries likeeth1:with empty lanes. The Python version correctly skips blank lines, fixing 30 HwSKUs.How to verify it