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

[Bug]: Non-interactive search with limit=1 much slower when query is empty #2367

Open
1 task done
jedrzejboczar opened this issue Aug 21, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@jedrzejboczar
Copy link

What did you expect to happen?

I wanted to use https://gist.github.com/tyalie/7e13cfe2ec62d99fa341a07ed12ef7c0 (from #798) and I noticed that searching is sometimes very slow for me (250 ms which is very noticeable when using up-arrow to cycle through history). This happens when query is empty. With an initial query string, even a single letter, it is much faster (30ms).

What happened?

I compared the time for atuin search invocations:

time atuin search --filter-mode global --search-mode prefix --limit 1 --offset 1 --cmd-only 'w'
0.02s user 0.01s system 94% cpu 0.031 total
time atuin search --filter-mode global --search-mode prefix --limit 1 --offset 1 --cmd-only
0.15s user 0.09s system 97% cpu 0.250 total

I tried to debug the SQL query used but I couldn't find any way to log it. I tried running with strace -f atuin search ..., while I didn't see much interesting stuff, the output length (number of system calls) is drastically different, compare:

> wc -l /tmp/out-with-query /tmp/out-no-query
     4393 /tmp/out-with-query
   109741 /tmp/out-no-query

I would expect to see somewhat similar time as I am only trying to search with --limit 1 and small offset, so that should be pretty fast.

Just for reference, atuin stats shows me Total commands: 240675.

Atuin doctor output

{
  "atuin": {
    "version": "18.3.0",
    "sync": {
      "cloud": true,
      "records": true,
      "auto_sync": true,
      "last_sync": "2024-08-21 7:34:41.277072878 +00:00:00"
    },
    "sqlite_version": "3.44.0"
  },
  "shell": {
    "name": "zsh",
    "default": "zsh",
    "plugins": [
      "atuin"
    ],
    "preexec": "built-in"
  },
  "system": {
    "os": "Arch Linux",
    "arch": "x86_64",
    "version": "rolling",
    "disks": [
      {
        "name": "/dev/nvme0n1p2",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/nvme0n1p1",
        "filesystem": "vfat"
      },
      {
        "name": "/dev/sdb1",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/sdb1",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/sdb1",
        "filesystem": "ext4"
      }
    ]
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jedrzejboczar jedrzejboczar added the bug Something isn't working label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant