Skip to content

CLI commands are slow to start #102

Open
@tegefaulkes

Description

@tegefaulkes

Specification

There seems to be a lead time before running Polykey does anything. this is demonstrated by running polykey --help to get the help text. This alone takes about 0.5 seconds on my work laptop.

[nix-shell:~/workspace/Polykey-CLI]$ time node dist/polykey --help
Usage: polykey [options] [command]

Polykey CLI

<Help text helpfully redacted to save space in issue>

real    0m0.493s
user    0m0.465s
sys     0m0.078s

Compare this to polykey bootstrap command which does some password hashing and state creation.

[nix-shell:~/workspace/Polykey-CLI]$ time node dist/polykey bootstrap -pf tmp/pass -np tmp/asd2
<recovery code redacted>

real    0m1.854s
user    0m1.613s
sys     0m0.344s

So a good 500ms is spent doing something before anything really runs. We can start by checking that we're importing all of polykey before running any command. After that the likely culprit is commander.

Additional context

Related: #40

Tasks

  1. Check that we don't blindly import all of Polykey during the import stage of the code. Large parts of Polykey should only be imported when the command is run, no when it is defined.
  2. Look into Commander to see if that could be the source of the slow startup time.
  3. Fix anything causing the slow startup time when running Polykey-CLI.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions