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

Bash completion for show/config commands has gotten slow #408

Open
jleveque opened this issue Dec 7, 2018 · 7 comments
Open

Bash completion for show/config commands has gotten slow #408

jleveque opened this issue Dec 7, 2018 · 7 comments
Assignees
Labels

Comments

@jleveque
Copy link
Contributor

jleveque commented Dec 7, 2018

It appears as though the slowdown is present on both the master and 201803 branches. Need to find what caused the slowdown and fix it.

@jleveque jleveque self-assigned this Dec 7, 2018
@jleveque jleveque added the Bug label Dec 7, 2018
@ishidawataru
Copy link
Contributor

ishidawataru commented Jan 5, 2019

One of the reasons of the slowness is this

Original show command takes 1.376s for the execution.
Using https://github.com/ninjaaron/fast-entry_points reduced that to 0.760s.

I'll open a PR for this.

@jleveque
Copy link
Contributor Author

Confirmed the slowdown is caused by the line from pkg_resources import load_entry_point as below:

root@str-s6000-acs-9:/# env 'COMP_WORDS=show ' COMP_CWORD=1 _SHOW_COMPLETE=complete pdb /usr/bin/show 
> /usr/bin/show(3)<module>()
-> __requires__ = 'sonic-utilities==1.2'
(Pdb) n
> /usr/bin/show(4)<module>()
-> import sys
(Pdb) 
> /usr/bin/show(5)<module>()
-> from pkg_resources import load_entry_point

@ishidawataru
Copy link
Contributor

@jleveque Correct.

With #426, fastentrypoints doesn't import pkg_resources, which can speed up the tab completion.

Here is the show command script after applying #426

root@100310f19a75:/data# cat /usr/local/bin/show
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
# EASY-INSTALL-ENTRY-SCRIPT: 'sonic-utilities==1.2','console_scripts','show'
__requires__ = 'sonic-utilities==1.2'
import re
import sys

from show.main import cli

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())

@jleveque
Copy link
Contributor Author

jleveque commented Feb 8, 2019

@ishidawataru: Is that output from an image built on the master branch? Why is your show wrapper file located at /usr/local/bin/show? I'm running a build off the head of the master branch as of yesterday, and my show wrapper is at /usr/bin/show and still contains the import statement:

root@sonic:~# cat /usr/bin/show
#! /usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'sonic-utilities==1.2','console_scripts','show'
__requires__ = 'sonic-utilities==1.2'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('sonic-utilities==1.2', 'console_scripts', 'show')()
    )

What's different between our builds?

@ishidawataru
Copy link
Contributor

I ran the following at the top directory of sonic-utilities repo.

$ docker run -v `pwd`:/data -w /data python:3.7.2 sh -c 'python3 setup.py install && cat `which show`'

It seems the build system is installing this repo differently?
I'll investigate.

@jleveque
Copy link
Contributor Author

jleveque commented Feb 8, 2019

Yes. The build system builds the sonic-utilities Python package into a .deb package and installs it using dpkg -i.

@wait2035
Copy link

will you address this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants