Skip to content
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

[sonic_py_common] Cache Static Information in device_info to speed up CLI response #11696

Merged
merged 5 commits into from
Aug 24, 2022

Conversation

vivekrnv
Copy link
Contributor

@vivekrnv vivekrnv commented Aug 11, 2022

Why I did it

Profiled the execution for the following cmd intfutil -c status

Before Optimization:

root@msn-2410:/home/admin# time intfutil -c status
...................
...................
real    0m1.619s
user    0m1.221s
sys     0m0.203s

root@msn-2410:/home/admin#python3 -m cProfile -s tottime /usr/local/bin/intfutil -c status
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      124    0.007    0.000    1.318    0.011 device_info.py:353(get_platform_info)
      124    0.002    0.000    0.890    0.007 device_info.py:332(get_sonic_version_info)
      128    0.002    0.000    0.202    0.002 device_info.py:42(get_localhost_info)
      128    0.001    0.000    0.203    0.002 device_info.py:128(get_hwsku)
       62    0.000    0.000    0.014    0.000 device_info.py:449(is_chassis)

After Optimization:

root@msn-2410:/home/admin# time intfutil -c status
...................
...................
real    0m0.883s
user    0m0.622s
sys     0m0.128s

root@msn-2410:/home/admin#python3 -m cProfile -s tottime /usr/local/bin/intfutil -c status
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      124    0.000    0.000    0.013    0.000 device_info.py:360(get_platform_info)
        1    0.000    0.000    0.009    0.009 device_info.py:336(get_sonic_version_info)
        5    0.000    0.000    0.008    0.002 device_info.py:46(get_localhost_info)
        5    0.000    0.000    0.008    0.002 device_info.py:132(get_hwsku)
       62    0.000    0.000    0.015    0.000 device_info.py:446(is_chassis)

How I did it

  1. Cached the following information:
    • get_sonic_version_info()
    • get_platform_info()
  2. None of the API exposed to the user libraries (for eg: sonic-utilities) has been modified

These methods involve reading text files or from redis. Thus, caching helped to improve the execution time

How to verify it

  • Added UT's.
  • Verified on the device

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

vivekrnv and others added 5 commits August 9, 2022 22:13
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@vivekrnv vivekrnv marked this pull request as ready for review August 11, 2022 03:05
@liat-grozovik liat-grozovik merged commit 0193c8e into sonic-net:master Aug 24, 2022
@liat-grozovik liat-grozovik added the Request for 202111 Branch For PRs being requested for 202111 branch label Aug 24, 2022
@dgsudharsan dgsudharsan removed the Request for 202111 Branch For PRs being requested for 202111 branch label Aug 25, 2022
yxieca pushed a commit that referenced this pull request Aug 26, 2022
… CLI response (#11696)

- Why I did it
Profiled the execution for the following cmd intfutil -c status

- How I did it
Cached the following information:
1. get_sonic_version_info()
2. get_platform_info()
None of the API exposed to the user libraries (for eg: sonic-utilities) has been modified
These methods involve reading text files or from redis. Thus, caching helped to improve the execution time

- How to verify it
Added UT's.
Verified on the device

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@yxieca
Copy link
Contributor

yxieca commented Aug 27, 2022

@vivekrnv this PR causes build failure in 202205 branch. Please raise separate if needed for 202205 branch.

vivekrnv added a commit to vivekrnv/sonic-buildimage that referenced this pull request Aug 29, 2022
… CLI response (sonic-net#11696)

- Why I did it
Profiled the execution for the following cmd intfutil -c status

- How I did it
Cached the following information:
1. get_sonic_version_info()
2. get_platform_info()
None of the API exposed to the user libraries (for eg: sonic-utilities) has been modified
These methods involve reading text files or from redis. Thus, caching helped to improve the execution time

- How to verify it
Added UT's.
Verified on the device

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@vivekrnv
Copy link
Contributor Author

@vivekrnv this PR causes build failure in 202205 branch. Please raise separate if needed for 202205 branch.

Hi @yxieca , PFA backport PR: #11866

yxieca pushed a commit that referenced this pull request Aug 29, 2022
… speed up CLI response (#11866)

* [sonic_py_common] Cache Static Information in device_info to speed up CLI response (#11696)

- Why I did it
Profiled the execution for the following cmd intfutil -c status

- How I did it
Cached the following information:
1. get_sonic_version_info()
2. get_platform_info()
None of the API exposed to the user libraries (for eg: sonic-utilities) has been modified
These methods involve reading text files or from redis. Thus, caching helped to improve the execution time

- How to verify it
Added UT's.
Verified on the device

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>

* Removed UT since libswsscommom dep is missing in <=202205

Signed-off-by: Vivek Reddy <vkarri@nvidia.com>

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy <vkarri@nvidia.com>
lukasstockner pushed a commit to genesiscloud/sonic-buildimage that referenced this pull request Apr 9, 2023
… speed up CLI response (sonic-net#11866)

* [sonic_py_common] Cache Static Information in device_info to speed up CLI response (sonic-net#11696)

- Why I did it
Profiled the execution for the following cmd intfutil -c status

- How I did it
Cached the following information:
1. get_sonic_version_info()
2. get_platform_info()
None of the API exposed to the user libraries (for eg: sonic-utilities) has been modified
These methods involve reading text files or from redis. Thus, caching helped to improve the execution time

- How to verify it
Added UT's.
Verified on the device

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>

* Removed UT since libswsscommom dep is missing in <=202205

Signed-off-by: Vivek Reddy <vkarri@nvidia.com>

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy <vkarri@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants