hluk / CopyQ

Clipboard manager with advanced features
GNU General Public License v3.0
8.69k stars 441 forks source link

Performance hit when using Encryption plugin #2537

Open realchrisolin opened 11 months ago

realchrisolin commented 11 months ago

Before creating a new issue, see list of known issues.

Describe the bug A noticeable performance hit is observed when using the Encryption plugin that lasts several minutes and causes the application to freeze.

To Reproduce Steps to reproduce the behavior:

  1. install any version of CopyQ built after a7a891e1
  2. configure encrypted tab history to 5000 items
  3. populate clipboard history with items
  4. configure Encryption plugin
  5. click Apply

Expected behavior The Preferences window closes and the settings take effect

Screenshots I could probably provide a video/screen recording on demand

Version, OS and Environment (Get details from copyq version command if possible.)

Additional context I believe the issue is a bottleneck between gpg and CopyQ that occurs when CopyQ is launched (while the encryption plugin is enabled) or after clicking Ok/Apply from the preferences window when the encryption plugin is enabled and there's a significant number of items being encrypted/decrypted. I'm not sure what exactly is happening in the background that causes this, but I suspect CopyQ is calling gpg to load/decrypt all of the items in the encrypted tab into memory which causes CopyQ to lock up until that operation has finished. It's also worth noting I saw similar performance prior to the recent rewrite of the plugin, to clarify this behavior isn't new.

At minimum, additional details in CopyQ's docs as it applies to the encryption plugin about what exactly is causing this performance bottleneck and what can be done to mitigate it would be appreciated. Adding asynchronous support (if possible, see https://stackoverflow.com/questions/59667777/truly-asynchronous-file-io-in-c) would be greatly appreciated.

hluk commented 10 months ago

I fail to reproduce the issue with large amount of larger items being encrypted. The delay of saving the whole tab again is just a few seconds on my system.