jwiegley / emacs-async

Simple library for asynchronous processing in Emacs
GNU General Public License v3.0
837 stars 68 forks source link

Skip async for fast operations #144

Closed darkfeline closed 2 years ago

darkfeline commented 3 years ago

Starting an async process for fast operations is clunky, so add a new option/feature for skipping async if the operation is fast. Same device renames are fast (since it's just a directory entry change) and renames and copys of small files are fast (arbitrarily picking 5 MB as the cutoff for modern computers/disks, can be configured).

thierryvolpiatto commented 3 years ago

darkfeline @.***> writes:

Starting an async process for fast operations is clunky, so add a new option/feature for skipping async if the operation is fast.

I agree it is fast to copy small files or rename on same disk but is it really worth the effort to switch to a sync copy for such cases, it is perhaps slower to run an async process for such files, but how much do you win by running sync? Note also that if you use helm, C-u M-C/R switch to sync.

Thanks.

-- Thierry

darkfeline commented 3 years ago

Renaming a file in the same directory using dired-async hangs for a good 2-4 seconds (specifically, any async operation that finishes too quickly). So this saves me 2-4 seconds each rename.

I guess I always assumed that that's just how dired-async works (maybe it's waiting for a subprocess that already ended?), but maybe we should fix that bug instead? Assuming it is a bug and not WAI.

I don't use helm.

thierryvolpiatto commented 3 years ago

darkfeline @.***> writes:

Renaming a file in the same directory using dired-async hangs for a good 2-4 seconds (specifically, any async operation that finishes too quickly).

Can't reproduce this, it is instant for me here.

-- Thierry

darkfeline commented 3 years ago

Hm, this is going to be one of those tricky bugs to reproduce. I have a hunch it has to do with having NFS mounted buffers open.

vnckppl commented 2 years ago

For me there is also a delay with async that I don't experience with the built in renaming/copying in dired. I just added this code to my init to toggle between enabling and disabling async:

;; Async toggle
(defun vk-toggle-async ()
  "Toggle enabling and disabling async"
  (interactive)
  (if (eq dired-async-mode nil)
      (progn
        (call-interactively 'dired-async-mode)
        (message "Async enabled"))
    (progn
      (progn
        (call-interactively 'dired-async-mode)
        (message "Async disabled"))
    )))
thierryvolpiatto commented 2 years ago

What about M-x dired-async-mode? ;-)

skangas commented 2 years ago

darkfeline @.***> writes: Renaming a file in the same directory using dired-async hangs for a good 2-4 seconds (specifically, any async operation that finishes too quickly). Can't reproduce this, it is instant for me here.

I can reproduce this with 100 % accuracy, but I have old drives (not SSD). My machine has pretty bad performance characteristics in general. Not sure what other details to give.

In any case, I'd appreciate if this was merged.

thierryvolpiatto commented 2 years ago

Ok merged.

skangas commented 2 years ago

Thanks!