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

fix(picker): cache apropos result to speed up :Telescope man_pages #3399

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

delphinus
Copy link
Member

Description

:Telescope man_pages uses output from the command: apropos. This is too slow command to use for this.

~ ❯❯❯ hyperfine -w 5 -N 'apropos .'
Benchmark 1: apropos .
  Time (mean ± σ):      1.457 s ±  0.082 s    [User: 0.386 s, System: 1.004 s]
  Range (min … max):    1.317 s …  1.556 s    10 runs

This patch caches the output and reuse it until it becomes stale. Now it detects it is “stale” if the cache file mtime is older than 86400s before.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I confirmed it works on macOS and Linux. But I didn't write unit tests.

  • :Telescope man_pages opens fast because of cache
  • Deleted cache, and :Telescope man_pages opens slowly again

Configuration:

  • Neovim version (nvim --version): NVIM v0.11.0-dev-4649+g6719276040-Homebrew
  • Operating system and version: macOS Sequoia 15.1.1

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

@delphinus delphinus force-pushed the feat/cache-man-pages branch from fb11712 to 1d9a70e Compare January 8, 2025 09:27
@Conni2461
Copy link
Member

I dont see a reason for caching ... 1s is not that slow. This just adds overhead for one specific picker

@delphinus
Copy link
Member Author

delphinus commented Jan 14, 2025

∆When I tested clean-installed Ubuntu, this takes <10ms and :Telescope man_pages makes no lags. In comparison with standard Linux, macOS has huge amount of man pages in default settings, so users (I) feel annoyance with using it.

As another suggestion, it is good if a cacheable finder exists in telescope. It may cache results of the same command execution. I think it is useful when users expect the same results from async_oneshot_finder. Can you accept such finder instead of adding this patch?

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 this pull request may close these issues.

2 participants