Bazel: Fish completion takes a long time to load on every shell start

Created on 2 Oct 2020  路  5Comments  路  Source: bazelbuild/bazel

Description of the problem / feature request:

After sourcing fish completions, autocomplete a bazel command, note how the shell hangs while the completion script parses the output of various bazel invocations.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Source fish completions, try to autocomplete bazel info --.

What operating system are you running Bazel on?

sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H2

fish --version
fish, version 3.1.2

What's the output of bazel info release?

release 3.3.0

Have you found anything relevant by searching the web?

Issue requesting fish completions: https://github.com/bazelbuild/bazel/issues/5088
Initial implementation: https://github.com/bazelbuild/bazel/pull/11450/files

Any other information, logs, or outputs that you want to share?

Note bash completions and zsh completions don't have the same issue: bash completions invoke bazel at build time, and generate a completion script from that, and zsh completions support caching.

help wanted team-XProduct

Most helpful comment

Yes, have tested https://github.com/bazelbuild/bazel/pull/12249 and I can build it, and it solves all 5 issues! Thanks for the quick response.

All 5 comments

cc @tmandry @akirabaruah

Seems like the simplest way to speed things up is to generate fish completions at build time like we do for bash. I'm happy to make that change, if needed - should be able to do so by the end of this weekend.

Took a bit longer than expected, but I've put up PR #12249 to generate the fish completion script at build time. Sourcing the generated file is significantly faster (~200ms vs. ~3s on my machine), while maintaining the same functionality as before.

Here's an example script (bazel.fish.gz) built at d69744dca68f8258762d53a01d8dca3afb7ed2ac + PR #12249 for convenience. @uri-canva let me know if it works for you if you get a chance - thanks!

Since we no longer have to parse strings in fish itself, the fix for this issue might supersede these:

  • #12206
  • #12207
  • #12208
  • #12209

Yes, have tested https://github.com/bazelbuild/bazel/pull/12249 and I can build it, and it solves all 5 issues! Thanks for the quick response.

Was this page helpful?
0 / 5 - 0 ratings