larkery / zsh-histdb

A slightly better history for zsh
MIT License
1.27k stars 75 forks source link

Performance metrics #2

Open jamescostian opened 7 years ago

jamescostian commented 7 years ago

Hi! I really love how well put together this all looks - from the merging driver to even describing with clear code examples how to wire this up to zsh-autosuggestions, I must say, this looks very well made. But I'm very interested in what the performance of it is - e.g. what is the performance impact on running a command due to this zshaddhistory given X items of history, or what happens to zsh-autosuggestions with this SQLite DB vs the plain old .zsh_history

I would be happy to record some of these metrics on my computer and send a pull request, but I'm wondering if you think this is a good idea or not really important.

Anyway, thanks for making this!

larkery commented 7 years ago

Some performance information would go well in the readme, if you want to do some experiments and write the results down I would happily accept a pull request.

It may be as simple as a loop like

for x in $(seq 1 1000000); do
    ## start a timer
    for y in $(seq 1 1000); do
       zshaddhistory bogus command $x or something
       ## similarly do timings on query function
    done
    ## work out time deltas
    echo $x $delta_timer1 $delta_timer2
done

to see how the insert & query times vary with number of elements in history.

timblaktu commented 6 years ago

I second everything @jamescostian says and asks here. I am not yet using zsh-histdb but it appears to provide the holy grail of history management across many machines (as long as performance isn't considerably worse, esp as the sqlite db scales up), so I intend to give it a go. I was surprised to not find any performance metrics - I think I read too much between the lines when I saw @larkery 's strace example in the README. ;-)

larkery commented 6 years ago

I haven't done any profiling, but I use this on many machines and have something like 30K entries now, haven't noticed any problems. I think about twice I have seen a lock collision where two shells tried to write at the same time and one of them didn't get in.