abo-abo/swiper

counsel-yank-pop is very slow

a13 opened this issue · 3 comments

a13 commented

My (emacs-uptime) is 80 days so far and kill-ring has 10k elements in it. The default (benchmark-run (counsel--yank-pop-kills)) runs in 14s, mostly because of two reasons:

  • equal-including-properties is slow
  • cl-delete-duplicates is very slow (if I use -distinct with the same comparator, it's 2.5 times faster)

Could you provide the way to customize the way we compare elements in kill-ring or to remove the usage equal-including-properties completely (this way we can use delete-dups or seq-uniq).

Thanks.

kill-ring has 10k elements in it.

Is that an explicit choice on your part, by customising kill-ring-max? Or does your kill-ring somehow grow beyond kill-ring-max elements?

Could you provide the way to customize the way we compare elements in kill-ring or to remove the usage equal-including-properties completely (this way we can use delete-dups or seq-uniq).

This should be doable, but note that this would diverge from the built-in behaviour: kill-new uses equal-including-properties when the user option kill-do-not-save-duplicates is non-nil.

Another option would be to deduplicate in counsel-yank-pop only when the user option kill-do-not-save-duplicates is non-nil. But this might confuse users who are used to the current behaviour of unconditionally deduplicating.

a13 commented

Is that an explicit choice on your part, by customising kill-ring-max?

correct

Another option would be to deduplicate in counsel-yank-pop only when the user option kill-do-not-save-duplicates is non-nil.

it's still an option, yes. But consult for example, just ignores properties.

Which Emacs version are you on? If you're on 28 or newer, I think PR #3045 should improve performance. If you can test it before I merge, that would be great; otherwise I'll merge it later this week and everyone can become a tester :).