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

Help is super slow in v3 #101

Closed
childish-sambino opened this issue Jul 8, 2020 · 2 comments · May be fixed by Omrisnyk/snyk-disallow#27
Closed

Help is super slow in v3 #101

childish-sambino opened this issue Jul 8, 2020 · 2 comments · May be fixed by Omrisnyk/snyk-disallow#27

Comments

@childish-sambino
Copy link
Contributor

With "@oclif/plugin-help": "^2.2.3",:

➜ time twilio
unleash the power of Twilio from your command prompt

VERSION
  twilio-cli/2.4.0 darwin-x64 node-v10.21.0

USAGE
  $ twilio [COMMAND]

COMMANDS
  api            advanced access to all of the Twilio APIs
  autocomplete   display autocomplete installation instructions
  debugger       Show a list of log events generated for the account
  email          sends emails to single or multiple recipients using Twilio SendGrid
  feedback       provide feedback to the CLI team
  help           display help for twilio
  login          create a new profile to store Twilio Account credentials and configuration
  phone-numbers  manage Twilio phone numbers
  plugins        list available plugins for installation
  profiles       manage credentials for Twilio profiles
  rtc            A plugin which showcases real-time communication applications powered by Twilio

twilio  0.70s user 0.16s system 114% cpu 0.756 total

With "@oclif/plugin-help": "^3.1.0",:

➜ time twilio
unleash the power of Twilio from your command prompt

VERSION
  twilio-cli/2.4.0 darwin-x64 node-v10.21.0

USAGE
  $ twilio [COMMAND]

TOPICS
  api            advanced access to all of the Twilio APIs
  debugger       Show a list of log events generated for the account
  email          sends emails to single or multiple recipients using Twilio SendGrid
  feedback       provide feedback to the CLI team
  phone-numbers  manage Twilio phone numbers
  plugins        list available plugins for installation
  profiles       manage credentials for Twilio profiles
  rtc            A plugin which showcases real-time communication applications powered by Twilio

COMMANDS
  autocomplete  display autocomplete installation instructions
  feedback      provide feedback to the CLI team
  help          display help for twilio
  login         create a new profile to store Twilio Account credentials and configuration
  plugins       list installed plugins

twilio  22.67s user 0.41s system 97% cpu 23.638 total
childish-sambino pushed a commit to twilio/twilio-cli-core that referenced this issue Jul 8, 2020
Stay on v2 until sluggishness is resolved: oclif/plugin-help#101
childish-sambino pushed a commit to twilio/twilio-cli that referenced this issue Jul 8, 2020
Stay on v2 until sluggishness is resolved: oclif/plugin-help#101
@RasPhilCo
Copy link
Contributor

Interesting, thanks for reporting. Didn't notice this but will take a further look. cc @chadian

@rbergman
Copy link
Contributor

We have noticed significant performance problems with help in a new multi command CLI under development that contains a very large number of overall topics and commands in a hierarchical structure.

A short investigation of the issue we are observing can be fixed for our case by locally caching the value of this.config.topics outside the filter loop in this function of index.ts as shown below.

  private get _topics(): Config.Topic[] {
    return this.config.topics.filter((topic: Config.Topic) => {
      // it is assumed a topic has a child if it has children
      const hasChild = this.config.topics.some(subTopic => subTopic.name.includes(`${topic.name}:`))
      return hasChild
    })
  }

Rewriting it as follows reduces our help output time from ~5.5s to ~300ms (with a prepared oclif.manifest.json available):

  private get _topics(): Config.Topic[] {
    // since this.config.topics is a getter that does non-trivial work, cache it outside the filter loop for
    // performance benefits in the presence of large numbers of topics
    const topics = this.config.topics;
    return topics.filter((topic: Config.Topic) => {
      // it is assumed a topic has a child if it has children
      const hasChild = topics.some(subTopic => subTopic.name.includes(`${topic.name}:`))
      return hasChild
    })
  }

I'll prepare a PR containing this shortly.

rbergman added a commit to rbergman/plugin-help that referenced this issue Jan 21, 2021
rbergman added a commit to rbergman/plugin-help that referenced this issue Jan 21, 2021
oclif-bot added a commit that referenced this issue Feb 3, 2021
## [3.2.2](v3.2.1...v3.2.2) (2021-02-03)

### Bug Fixes

* avoid recomputing topics in loop ([#189](#189)) ([eccb862](eccb862)), closes [#101](#101)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants