[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 .device_data import DeviceDataManager
|
||||
from .sfp import SFP, deinitialize_sdk_handle
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
@ -113,8 +112,10 @@ class Chassis(ChassisBase):
|
||||
if self.sfp_event:
|
||||
self.sfp_event.deinitialize()
|
||||
|
||||
if SFP.shared_sdk_handle:
|
||||
deinitialize_sdk_handle(SFP.shared_sdk_handle)
|
||||
if self._sfp_list:
|
||||
from .sfp import SFP, deinitialize_sdk_handle
|
||||
if SFP.shared_sdk_handle:
|
||||
deinitialize_sdk_handle(SFP.shared_sdk_handle)
|
||||
|
||||
##############################################
|
||||
# PSU methods
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
import glob
|
||||
import os
|
||||
from sonic_py_common import device_info
|
||||
|
||||
from . import utils
|
||||
|
||||
@ -173,6 +172,7 @@ class DeviceDataManager:
|
||||
@classmethod
|
||||
@utils.read_only_cache()
|
||||
def get_platform_name(cls):
|
||||
from sonic_py_common import device_info
|
||||
return device_info.get_platform()
|
||||
|
||||
@classmethod
|
||||
|
Loading…
Reference in New Issue
Block a user