From 95cacde4fcccc95c25d6fb9988d2aa097193f8c0 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sat, 22 Oct 2016 19:28:35 -0500 Subject: [PATCH] Inhibit fsync when refining hunks * (magit-diff-update-hunk-refinement): Set write-region-inhibit-fsync to prevent (smerge-refine-chopup-region) from calling fsync every time it calls (write-region). This results in an enormous performance improvement when magit-diff-refine-hunk is 'all. Since (smerge-refine-chopup-region) writes many small files for each hunk, calling fsync on each one is very slow. Inhibiting fsync for these calls prevents them from hitting the disk, making them very fast. --- lisp/magit-diff.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el index 8d6be71d15..120903092d 100644 --- a/lisp/magit-diff.el +++ b/lisp/magit-diff.el @@ -2235,7 +2235,9 @@ are highlighted." (goto-char (magit-section-start section)) ;; `diff-refine-hunk' does not handle combined diffs. (unless (looking-at "@@@") - (diff-refine-hunk)))) + ;; Avoid fsyncing many small temp files + (let ((write-region-inhibit-fsync t)) + (diff-refine-hunk))))) ((or `(nil t ,_) `(t t nil)) (setf (magit-section-refined section) nil) (remove-overlays (magit-section-start section)