<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: YDK Performance issue in Tools</title>
    <link>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809269#M2240</link>
    <description>&lt;P&gt;I am converting some data from text to json using textfsm and YDK&lt;/P&gt;
&lt;P&gt;it take 30 second for 2000 interface when I am using "Cisco-IOS-XR-infra-statsd-oper:interfaces" yang model and it take 200 second with another customized YANG Model.&lt;/P&gt;
&lt;P&gt;I am trying to minimize the time to 1 or 2 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below sample for two interfaces&lt;/P&gt;
&lt;P&gt;attached debugging file or below link&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive.google.com/open?id=188N1bbozpIJO9n4m4uAf5rrhatmwfxDU" target="_blank" rel="noopener"&gt;https://drive.google.com/open?id=188N1bbozpIJO9n4m4uAf5rrhatmwfxDU&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Cisco-IOS-XR-infra-statsd-oper:interfaces": {&lt;BR /&gt;"interface": [&lt;BR /&gt;{&lt;BR /&gt;"interface-name": "BVI30",&lt;BR /&gt;"data-rate": {&lt;BR /&gt;"input-data-rate": "8000",&lt;BR /&gt;"output-data-rate": "5000"&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"interface-name": "BVI2000",&lt;BR /&gt;"data-rate": {&lt;BR /&gt;"input-data-rate": "0",&lt;BR /&gt;"output-data-rate": "0"&lt;BR /&gt;}&lt;BR /&gt;},&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below function that take 200 seconds to get the json output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE style="background-color: #272822; color: #f8f8f2; font-family: 'Courier New'; font-size: 6.0pt;"&gt;&lt;FONT size="2"&gt;&lt;SPAN style="color: #66d9ef; font-style: italic;"&gt;def &lt;/SPAN&gt;&lt;SPAN style="color: #a6e22e;"&gt;interfaces_fun&lt;/SPAN&gt;(&lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;)&lt;SPAN style="color: #f92672;"&gt;:&lt;BR /&gt;&lt;/SPAN&gt;    fsm_results, re_header_dic &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.&lt;SPAN style="color: #66d9ef;"&gt;parse_text_fsm&lt;/SPAN&gt;()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    end &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;time.&lt;SPAN style="color: #66d9ef;"&gt;time&lt;/SPAN&gt;()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    &lt;SPAN style="color: #66d9ef;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #e6db74;"&gt;"Total time Before Loop: {}"&lt;/SPAN&gt;.&lt;SPAN style="color: #66d9ef;"&gt;format&lt;/SPAN&gt;(end &lt;SPAN style="color: #f92672;"&gt;- &lt;/SPAN&gt;start))&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    &lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.interfaces &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;show_interfaces.&lt;SPAN style="color: #66d9ef;"&gt;InterfaceInformation&lt;/SPAN&gt;()&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    &lt;SPAN style="color: #66d9ef; font-style: italic;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #66d9ef; font-style: italic;"&gt;in &lt;/SPAN&gt;fsm_results&lt;SPAN style="color: #f92672;"&gt;:&lt;BR /&gt;&lt;/SPAN&gt;        interface_name &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;row[re_header_dic[&lt;SPAN style="color: #e6db74;"&gt;'INTERFACE'&lt;/SPAN&gt;]]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;        one_interface_info &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.&lt;SPAN style="color: #66d9ef;"&gt;check_phy_logical&lt;/SPAN&gt;(interface_name)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;        one_interface_info.name &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;interface_name&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;        &lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.interfaces.physical_interface.&lt;SPAN style="color: #66d9ef;"&gt;append&lt;/SPAN&gt;(one_interface_info)&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    &lt;SPAN style="color: #66d9ef; font-style: italic;"&gt;return &lt;/SPAN&gt;&lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.interfaces&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below sample output for the code that take 200 second to generate the json output&lt;/P&gt;
&lt;P&gt;"show-interfaces:interface-information": {&lt;BR /&gt;"logical-interface": [&lt;BR /&gt;{&lt;BR /&gt;"name": "BVI30"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"name": "BVI2000"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"name": "BVI2077"&lt;BR /&gt;},&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Feb 2019 18:34:31 GMT</pubDate>
    <dc:creator>magedahmed</dc:creator>
    <dc:date>2019-02-25T18:34:31Z</dc:date>
    <item>
      <title>YDK Performance issue</title>
      <link>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809048#M2238</link>
      <description>&lt;P&gt;I am facing performance issue to add 2000 interfaces information under YANG models&lt;/P&gt;
&lt;P&gt;- yang model "from ydk.models.cisco_ios_xr import Cisco_IOS_XR_infra_statsd_oper" take about 30 seconds&lt;/P&gt;
&lt;P&gt;- yang model 'from ydk.models.juniper_show_interfaces import show_interfaces' take about 200 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there any way to improve performance issue?&lt;/P&gt;
&lt;P&gt;below the used code with Cisco YANG model&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;interfaces_fun&lt;/SPAN&gt;(&lt;SPAN&gt;self&lt;/SPAN&gt;)&lt;SPAN&gt;:&lt;BR /&gt;&lt;/SPAN&gt;    fsm_results, re_header_dic &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;self&lt;/SPAN&gt;.&lt;SPAN&gt;parse_text_fsm&lt;/SPAN&gt;()&lt;BR /&gt;    &lt;SPAN&gt;self&lt;/SPAN&gt;.interfaces &lt;SPAN&gt;= &lt;/SPAN&gt;Cisco_IOS_XR_infra_statsd_oper.InfraStatistics.&lt;SPAN&gt;Interfaces&lt;/SPAN&gt;()&lt;BR /&gt;    one_interface_info &lt;SPAN&gt;= &lt;/SPAN&gt;Cisco_IOS_XR_infra_statsd_oper.InfraStatistics.Interfaces.&lt;SPAN&gt;Interface&lt;/SPAN&gt;()&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;row &lt;SPAN&gt;in &lt;/SPAN&gt;fsm_results&lt;SPAN&gt;:&lt;BR /&gt;&lt;/SPAN&gt;        interface_name &lt;SPAN&gt;= &lt;/SPAN&gt;row[re_header_dic[&lt;SPAN&gt;'INTERFACE'&lt;/SPAN&gt;]]&lt;BR /&gt;        one_interface_info.interface_name &lt;SPAN&gt;= &lt;/SPAN&gt;interface_name&lt;BR /&gt;        one_interface_info.data_rate.input_data_rate &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;int&lt;/SPAN&gt;(row[re_header_dic[&lt;SPAN&gt;'INPUT_RATE_BITS'&lt;/SPAN&gt;]] &lt;SPAN&gt;or &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;)&lt;BR /&gt;        one_interface_info.data_rate.output_data_rate &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;int&lt;/SPAN&gt;(row[re_header_dic[&lt;SPAN&gt;'OUTPUT_RATE_BITS'&lt;/SPAN&gt;]] &lt;SPAN&gt;or &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;)&lt;BR /&gt;        &lt;BR /&gt;        &lt;SPAN&gt;self&lt;/SPAN&gt;.interfaces.interface.&lt;SPAN&gt;append&lt;/SPAN&gt;(one_interface_info)&lt;BR /&gt;&lt;BR /&gt;    &lt;SPAN&gt;return &lt;/SPAN&gt;&lt;SPAN&gt;self&lt;/SPAN&gt;.interfaces&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/817974"&gt;@ygorelik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 14:33:44 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809048#M2238</guid>
      <dc:creator>magedahmed</dc:creator>
      <dc:date>2019-02-25T14:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: YDK Performance issue</title>
      <link>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809177#M2239</link>
      <description>&lt;P&gt;What exactly is taking 200s? The import statement? The execution of the RPC? You may want to capture debug logs and share them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import logging

logger = logging.getLogger("ydk")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - "
                                      "%(levelname)s - %(message)s"))
handler.setFormatter(formatter)
logger.addHandler(handler)&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Feb 2019 16:39:57 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809177#M2239</guid>
      <dc:creator>saalvare</dc:creator>
      <dc:date>2019-02-25T16:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: YDK Performance issue</title>
      <link>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809269#M2240</link>
      <description>&lt;P&gt;I am converting some data from text to json using textfsm and YDK&lt;/P&gt;
&lt;P&gt;it take 30 second for 2000 interface when I am using "Cisco-IOS-XR-infra-statsd-oper:interfaces" yang model and it take 200 second with another customized YANG Model.&lt;/P&gt;
&lt;P&gt;I am trying to minimize the time to 1 or 2 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below sample for two interfaces&lt;/P&gt;
&lt;P&gt;attached debugging file or below link&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive.google.com/open?id=188N1bbozpIJO9n4m4uAf5rrhatmwfxDU" target="_blank" rel="noopener"&gt;https://drive.google.com/open?id=188N1bbozpIJO9n4m4uAf5rrhatmwfxDU&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Cisco-IOS-XR-infra-statsd-oper:interfaces": {&lt;BR /&gt;"interface": [&lt;BR /&gt;{&lt;BR /&gt;"interface-name": "BVI30",&lt;BR /&gt;"data-rate": {&lt;BR /&gt;"input-data-rate": "8000",&lt;BR /&gt;"output-data-rate": "5000"&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"interface-name": "BVI2000",&lt;BR /&gt;"data-rate": {&lt;BR /&gt;"input-data-rate": "0",&lt;BR /&gt;"output-data-rate": "0"&lt;BR /&gt;}&lt;BR /&gt;},&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below function that take 200 seconds to get the json output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE style="background-color: #272822; color: #f8f8f2; font-family: 'Courier New'; font-size: 6.0pt;"&gt;&lt;FONT size="2"&gt;&lt;SPAN style="color: #66d9ef; font-style: italic;"&gt;def &lt;/SPAN&gt;&lt;SPAN style="color: #a6e22e;"&gt;interfaces_fun&lt;/SPAN&gt;(&lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;)&lt;SPAN style="color: #f92672;"&gt;:&lt;BR /&gt;&lt;/SPAN&gt;    fsm_results, re_header_dic &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.&lt;SPAN style="color: #66d9ef;"&gt;parse_text_fsm&lt;/SPAN&gt;()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    end &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;time.&lt;SPAN style="color: #66d9ef;"&gt;time&lt;/SPAN&gt;()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    &lt;SPAN style="color: #66d9ef;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #e6db74;"&gt;"Total time Before Loop: {}"&lt;/SPAN&gt;.&lt;SPAN style="color: #66d9ef;"&gt;format&lt;/SPAN&gt;(end &lt;SPAN style="color: #f92672;"&gt;- &lt;/SPAN&gt;start))&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    &lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.interfaces &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;show_interfaces.&lt;SPAN style="color: #66d9ef;"&gt;InterfaceInformation&lt;/SPAN&gt;()&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    &lt;SPAN style="color: #66d9ef; font-style: italic;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #66d9ef; font-style: italic;"&gt;in &lt;/SPAN&gt;fsm_results&lt;SPAN style="color: #f92672;"&gt;:&lt;BR /&gt;&lt;/SPAN&gt;        interface_name &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;row[re_header_dic[&lt;SPAN style="color: #e6db74;"&gt;'INTERFACE'&lt;/SPAN&gt;]]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;        one_interface_info &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.&lt;SPAN style="color: #66d9ef;"&gt;check_phy_logical&lt;/SPAN&gt;(interface_name)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;        one_interface_info.name &lt;SPAN style="color: #f92672;"&gt;= &lt;/SPAN&gt;interface_name&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;        &lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.interfaces.physical_interface.&lt;SPAN style="color: #66d9ef;"&gt;append&lt;/SPAN&gt;(one_interface_info)&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;    &lt;SPAN style="color: #66d9ef; font-style: italic;"&gt;return &lt;/SPAN&gt;&lt;SPAN style="color: #94558d;"&gt;self&lt;/SPAN&gt;.interfaces&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below sample output for the code that take 200 second to generate the json output&lt;/P&gt;
&lt;P&gt;"show-interfaces:interface-information": {&lt;BR /&gt;"logical-interface": [&lt;BR /&gt;{&lt;BR /&gt;"name": "BVI30"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"name": "BVI2000"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"name": "BVI2077"&lt;BR /&gt;},&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 18:34:31 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809269#M2240</guid>
      <dc:creator>magedahmed</dc:creator>
      <dc:date>2019-02-25T18:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: YDK Performance issue</title>
      <link>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809310#M2241</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/575471"&gt;@magedahmed&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on my understanding, the issue seems to be that the import statement is taking too long. Correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please respond with the output of the below from command line to verify the issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;time python -c 'from ydk.models.cisco_ios_xr import Cisco_IOS_XR_infra_statsd_oper'

time python -c 'from ydk.models.juniper_show_interfaces import show_interfaces'
&lt;/PRE&gt;
&lt;P&gt;If the import statement is taking long, it may mean you have to increase your RAM. The&amp;nbsp;&lt;A href="https://github.com/YangModels/yang/blob/master/vendor/cisco/xr/651/Cisco-IOS-XR-infra-statsd-oper.yang" target="_self"&gt;Cisco-IOS-XR-infra-statsd-oper.yang&lt;/A&gt; model is not that big.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 19:10:59 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3809310#M2241</guid>
      <dc:creator>abhirame</dc:creator>
      <dc:date>2019-02-25T19:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: YDK Performance issue</title>
      <link>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3829493#M2242</link>
      <description>&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/547387"&gt;@abhirame&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;below the required output, Could you please advise if it is related to RAM or not?&lt;BR /&gt;&lt;BR /&gt;auto@yang-vm:~$ time python3 -c 'from ydk.models.cisco_ios_xr import Cisco_IOS_XR_infra_statsd_oper'&lt;BR /&gt;&lt;BR /&gt;real 0m7.505s&lt;BR /&gt;user 0m0.364s&lt;BR /&gt;sys 0m0.795s&lt;BR /&gt;auto@yang-vm:~$&lt;BR /&gt;&lt;BR /&gt;## The below about after I changed the yang file and it is very small now&lt;BR /&gt;auto@yang-vm:~$ time python3 -c 'from ydk.models.juniper_show_interfaces import show_interfaces'&lt;BR /&gt;&lt;BR /&gt;real 0m1.159s&lt;BR /&gt;user 0m0.349s&lt;BR /&gt;sys 0m0.033s</description>
      <pubDate>Sun, 31 Mar 2019 12:33:32 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/ydk-performance-issue/m-p/3829493#M2242</guid>
      <dc:creator>magedahmed</dc:creator>
      <dc:date>2019-03-31T12:33:32Z</dc:date>
    </item>
  </channel>
</rss>

