cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.92k stars 178 forks source link

Slow startup with large db #125

Open kuehnelth opened 3 years ago

kuehnelth commented 3 years ago

When I press Ctrl-r it takes 2 or so seconds until the search window appears. My mcfly history contains 130000 entries from using it for over 2 years. The file is 40 Megabytes large.

Not sure what the best way to improve this would be. Just deleting all or part of the history is probably the easiest.

cantino commented 3 years ago

Hey @kuehnelth, thanks for the report! I think you're ahead of me in usage :)

I just made a branch that adds a new MCFLY_HISTORY_LIMIT option. Would you be open to checking it out and setting the environment variable to something like 10000 (or whatever) to see how much it speeds up your load time?

kuehnelth commented 3 years ago

Hi, I tested it today. It's a bit faster but not a lot. I enabled the println at the end of build_cache_table.

$ MCFLY_HISTORY_LIMIT= ./target/release/mcfly search
Seconds: 1.336557859
$ MCFLY_HISTORY_LIMIT=10000 ./target/release/mcfly search
Seconds: 0.97758059
$ MCFLY_HISTORY_LIMIT=1 ./target/release/mcfly search
Seconds: 0.785006351
cantino commented 3 years ago

Thanks for testing! I have a better implementation in #126 now. Mind testing again?

kuehnelth commented 3 years ago

Sure. Here are the new results. Now it's quite a bit faster.

# MCFLY_HISTORY_LIMIT= ./target/release/mcfly search
Seconds: 1.06648488
# MCFLY_HISTORY_LIMIT=10000 ./target/release/mcfly search
Seconds: 0.290234198
# MCFLY_HISTORY_LIMIT=1 ./target/release/mcfly search
Seconds: 0.23848428
cantino commented 3 years ago

Great! I've merged the addition of MCFLY_HISTORY_LIMIT and will do a release soon.