Skip to content

Commit

Permalink
Speed up clish startup (#23)
Browse files Browse the repository at this point in the history
. All the ptypes were stored in a list and searched using string comparison

    — Use Binary tree instead (gives about 800ms improvement).

. Cleanup exact duplicate ptypes
. Fix use of LOG_TYPE with 2 different values.

    sonic# show logging filter type
      log:  log type

   After:

    sonic# show logging filter type
      <syslog/inmem/all>  log type
  • Loading branch information
joyas-joseph authored and GitHub Enterprise committed Feb 9, 2022
1 parent 252874e commit 7bd8789
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 95 deletions.
2 changes: 1 addition & 1 deletion CLI/clitree/cli-xml/file_mgmt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ permissions and limitations under the License. -->
</PARAM>
<PARAM name="copy_log_url"
help="Copy from &LOG_URL;"
ptype="LOG_TYPE">
ptype="LOG_PREF_TYPE">
<PARAM name="copy_log_options"
help="Copy log options"
ptype="SUBCOMMAND"
Expand Down
12 changes: 0 additions & 12 deletions CLI/clitree/cli-xml/ipsla.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,6 @@ limitations under the License.
pattern="1..1000"
help=""
/>
<PTYPE
name="RANGE_1_300"
method="integer"
pattern="1..300"
help=""
/>
<PTYPE
name="RANGE_0_65535"
method="integer"
pattern="0..65535"
help=""
/>

<!--=========================================================================-->
<VIEW name="enable-view">
Expand Down
2 changes: 0 additions & 2 deletions CLI/clitree/cli-xml/locator_led.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ limitations under the License.

<CLISH_MODULE xmlns="http://www.dellemc.com/sonic/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.dellemc.com/sonic/XMLSchema http://www.dellemc.com/sonic/XMLSchema/clish.xsd">
<!--=========================================================================-->
<PTYPE name="TIMER_VALUE" method="integer" pattern="1..120" help="minutes"/>
<!--=======================================================-->

<VIEW name="enable-view">
<!-- locator-led -->
Expand Down
3 changes: 0 additions & 3 deletions CLI/clitree/cli-xml/port_locator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ limitations under the License.
-->

<CLISH_MODULE xmlns="http://www.dellemc.com/sonic/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.dellemc.com/sonic/XMLSchema http://www.dellemc.com/sonic/XMLSchema/clish.xsd">
<!--=========================================================================-->
<PTYPE name="TIMER_VALUE" method="integer" pattern="1..120" help="minutes"/>
<!--=======================================================-->

<VIEW name="enable-view">
<!-- interface port-locator -->
Expand Down
7 changes: 0 additions & 7 deletions CLI/clitree/cli-xml/snmp_types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ Copyright 2020 Broadcom, Inc.
help="Octet (hex) string, 5-32 octets"
/>
<!--=======================================================-->
<PTYPE
name="RANGE_1_300"
method="integer"
pattern="1..300"
help=""
/>
<!--=======================================================-->
<PTYPE
name="LISTEN_PORT"
method="integer"
Expand Down
29 changes: 21 additions & 8 deletions CLI/clitree/cli-xml/sonic_types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ limitations under the License.
/>
<!--========================================================-->
<PTYPE
name="LOG_TYPE"
name="LOG_PREF_TYPE"
pattern="log:\/\/[^|]+"
help="log:"
/>
Expand Down Expand Up @@ -1807,13 +1807,6 @@ limitations under the License.
pattern="255"
help=""
/>
<!--=======================================================-->
<PTYPE
name="RANGE_0_47"
method="integer"
pattern="0..47"
help=""
/>
<!--=======================================================-->
<PTYPE
name="RANGE_1_600"
Expand Down Expand Up @@ -1957,5 +1950,25 @@ limitations under the License.
help="STRING"
/>
<!--=======================================================-->
<PTYPE
name="TIMER_VALUE"
method="integer"
pattern="1..120"
help="minutes"/>
<!--=======================================================-->
<PTYPE
name="RANGE_1_300"
method="integer"
pattern="1..300"
help=""
/>
<!--=======================================================-->
<PTYPE
name="BOOL_SELECT"
method="select"
pattern="yes(yes) no(no)"
help=""
/>
<!--=======================================================-->

</CLISH_MODULE>
2 changes: 0 additions & 2 deletions CLI/clitree/cli-xml/swsslog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
]>
<CLISH_MODULE xmlns="http://www.dellemc.com/sonic/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="http://www.dellemc.com/sonic/XMLSchema http://www.dellemc.com/sonic/XMLSchema/clish.xsd">

<PTYPE name="BOOL_SELECT" method="select" pattern="yes(yes) no(no)" help="" />

<VIEW name="enable-view">
<COMMAND help="Display components registered in DB for loglevel severity" name="show swsslog-configuration">
<ACTION builtin="clish_pyobj">sonic_cli_swsslog get_openconfig_loglevel_from_db tpcm.j2</ACTION>
Expand Down
7 changes: 0 additions & 7 deletions CLI/clitree/cli-xml/tpcm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
help="container_name"
/>

<PTYPE
name="BOOL_SELECT"
method="select"
pattern="yes(yes) no(no)"
help=""
/>


<VIEW name="enable-view">
<COMMAND
Expand Down
24 changes: 15 additions & 9 deletions CLI/klish/patches/klish-2.1.4/clish/ptype.h.diff
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
9d8
< typedef struct clish_ptype_s clish_ptype_t;
15c14
11a11
> #include "lub/bintree.h"
15c15
<
---
> #include "types.h"
16a16,18
16a17,19
> #include <stdbool.h>
>
> typedef struct clish_ptype_s clish_ptype_t;
33a36,37
33a37,38
> CLISH_PTYPE_METHOD_REGEXP_SELECT, /* dell-emc */
> CLISH_PTYPE_METHOD_TMZ_SELECT, /* dell-emc */
45a50,51
45a51,52
> /* for checking the mode attribute */
> CLISH_PTYPE_PRE_MODE,
49a56,62
49a57,63
> enum help_type_s {
> USE_NAME,
> USE_VALUE,
> USE_RANGE
> };
> typedef enum help_type_s help_type_t;
>
57c70,71
57c71,72
< clish_ptype_preprocess_e preprocess);
---
> clish_ptype_preprocess_e preprocess, const char *ext_pattern, const char *ext_help,
> const char *alt_ext_pattern, const char *alt_pattern);
68c82
68c83
< char *clish_ptype_validate(clish_ptype_t * instance, const char *text);
---
> char *clish_ptype_validate(clish_ptype_t * instance, const char *text, bool_t isHelp);
84c98
84c99
< lub_argv_t *matches, const char *text);
---
> lub_argv_t *matches, const char *text, const char *penultimate_text, bool_t order);
95c109,128
95c110,133
< const char *pattern, clish_ptype_method_e method);
---
> const char *pattern, clish_ptype_method_e method, const char *alt_pattern);
Expand All @@ -58,3 +60,7 @@
> extern bool nos_use_alt_name(void);
> char *clish_ptype_method_select__get_name(const clish_ptype_t *instance,unsigned int index);
> int clish_ptype_tmz_select__get_help(clish_help_t *help, const char *pval, bool_t order);
>
> int clish_ptype_bt_compare(const void *clientnode, const void *clientkey);
> void clish_ptype_bt_getkey(const void *clientnode, lub_bintree_key_t * key);
> size_t clish_ptype_bt_offset(void);
6 changes: 4 additions & 2 deletions CLI/klish/patches/klish-2.1.4/clish/ptype/private.h.diff
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
> lub_argv_t *alt_items;
> };
>
30a42,47
27a39
> lub_bintree_node_t bt_node;
30a43,48
>
> char *ext_pattern;
> char *ext_help;
> char *alt_ext_pattern;
> char *alt_pattern;
> help_type_t usename;
38a56
38a57
> clish_ptype_regexp_select_t regexp_select;
Loading

0 comments on commit 7bd8789

Please sign in to comment.