[Mellanox] optimize platform API import time (#10815)
- Why I did it "import sonic_platform" takes about 600ms ~ 1000ms, it is kind of slow. After this optimization, the time is about 100ms. The benefit is that those CLIs which does not need the slow import sentence would be faster than before. - How I did it Find slow import and call them when need. - How to verify it Measure the import time.
This commit is contained in:
parent
5c869492bd
commit
f135f37a50
@ -30,7 +30,6 @@ try:
|
|||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .device_data import DeviceDataManager
|
from .device_data import DeviceDataManager
|
||||||
from .sfp import SFP, deinitialize_sdk_handle
|
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError (str(e) + "- required module not found")
|
raise ImportError (str(e) + "- required module not found")
|
||||||
|
|
||||||
@ -113,6 +112,8 @@ class Chassis(ChassisBase):
|
|||||||
if self.sfp_event:
|
if self.sfp_event:
|
||||||
self.sfp_event.deinitialize()
|
self.sfp_event.deinitialize()
|
||||||
|
|
||||||
|
if self._sfp_list:
|
||||||
|
from .sfp import SFP, deinitialize_sdk_handle
|
||||||
if SFP.shared_sdk_handle:
|
if SFP.shared_sdk_handle:
|
||||||
deinitialize_sdk_handle(SFP.shared_sdk_handle)
|
deinitialize_sdk_handle(SFP.shared_sdk_handle)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
from sonic_py_common import device_info
|
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
@ -173,6 +172,7 @@ class DeviceDataManager:
|
|||||||
@classmethod
|
@classmethod
|
||||||
@utils.read_only_cache()
|
@utils.read_only_cache()
|
||||||
def get_platform_name(cls):
|
def get_platform_name(cls):
|
||||||
|
from sonic_py_common import device_info
|
||||||
return device_info.get_platform()
|
return device_info.get_platform()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Reference in New Issue
Block a user