atuinsh / atuin

✨ Magical shell history
https://atuin.sh
MIT License
18.62k stars 521 forks source link

atuin history gc? #2015

Open AlJohri opened 1 month ago

AlJohri commented 1 month ago

I seem to have accidentally re-run atuin import zsh after already using atuin for a period of time. I installed atuin on a new computer and kept syncing and was getting 0 results. I wasn't sure what was going on until I realized that the new installation was using the sync v2. I have since upgraded all installations to use sync v2, however as part of trying to figure out what was going on, I had re-run the atuin import zsh command and then run atuin sync. This appears to have doubled the size of my history from 150k records to 300k records.

Is there anyway I can "garbage collect" down to a list of unique entries and clean up my atuin history?

AlJohri commented 1 month ago

It seems like its taking almost 0.5 to 1 second when I press CTRL-R (not sure how to check exactly). Would love to figure out some way to trim some of this history down or speed up the TUI so CTRL-R is instantaneous.

As a proxy for timing, it takes about 5 seconds to run atuin history list:

❯ atuin history list | wc -l
366974

❯ time atuin history list &> /dev/null
atuin history list &> /dev/null  4.87s user 2.81s system 172% cpu 4.448 total
AlJohri commented 1 week ago

Looks like my slowdown is likely related to getting the unique set of commands: See https://github.com/atuinsh/atuin/issues/475

zuzzurro commented 1 week ago

I have the same issue. I am actually running "atuin import zsh" multiple times in order to incrementally save my zsh history before I actually really start using atuin and commands are added multiple times. Some sort of deduplication based on the time and command would be extremely appreciated.