GNU bug report logs - #29846
scroll and fontify takes longer time for file in slow network

Previous Next

Package: emacs;

Reported by: Shuguang Sun <shuguang <at> gmail.com>

Date: Mon, 25 Dec 2017 06:04:01 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29846 in the body.
You can then email your comments to 29846 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Mon, 25 Dec 2017 06:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Shuguang Sun <shuguang <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 25 Dec 2017 06:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Shuguang Sun <shuguang <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: scroll and fontify takes longer time for file in slow network
Date: Mon, 25 Dec 2017 14:03:43 +0800
[Message part 1 (text/plain, inline)]
Hi,

Windows 7, GNU Emacs 27.0.50 (build 1, x86_64-w64-mingw32) of 2017-12-09.

Issue:
I have remote dirver (//server/path) mapped to my windows system (samba?).
The network is slow, and it takes some time to open the file. However,
after I have the file opened and scroll down, it takes a long time to
scroll to the next screen. It gets worse if the jit-lock-debug-mode is on.
After that if I try to scroll back to those has been fontified, it get
fluent as expected.

If I open the same file in a local driver (speed is higher than the network
definitely), the scroll is very fluent.

If I open a txt file (fundmental-mode, not fontification) in the same
remote directory, the scroll actions are fluent as well.

Per my understanding, all actions should be done in memory when a file has
been read into buffer, except backup, autosave, etc. The response should
not depents on where the file located phically.

How to repeat it:
1. Find a slow transfer rate network (sorry, it may be hard)
2. Prepare a long c file, 3-4 screens.
3. take font-lock-mode on (jit-font-mode)
4. Open the c file and scroll down, scroll down, scroll down...
5. scroll up, scroll up, scroll up

I have tried profiler. It indicates, the jit-font and redisplay take
majority of the cpu time.
1. open the c file
2. profiler-start
3. scroll down, scroll down, scroll down...
4. profiler-report


Best Regards,
Shuguang Sun
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Mon, 25 Dec 2017 09:49:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Shuguang Sun <shuguang <at> gmail.com>
To: shuguang <at> gmail.com, bug-gnu-emacs <at> gnu.org
Subject: bug#29846: scroll and fontify takes longer time for file in slow
 network
Date: Mon, 25 Dec 2017 17:47:52 +0800
[Message part 1 (text/plain, inline)]
Backup, auto-save, and lockfiles has been disabled in .dir-locals

((nil
  (make-backup-files . nil)
  (create-lockfiles  . nil)
  (auto-save-default . nil)
  (auto-save-timeout . 10000)
  ))

Best Regards,
Shuguang
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Mon, 25 Dec 2017 12:30:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: bug-gnu-emacs <at> gnu.org, Shuguang Sun <shuguang <at> gmail.com>,
 shuguang <at> gmail.com, 29846 <at> debbugs.gnu.org
Subject: Re: bug#29846: scroll and fontify takes longer time for file in
 slow	network
Date: Mon, 25 Dec 2017 14:28:46 +0200
On December 25, 2017 11:47:52 AM GMT+02:00, Shuguang Sun <shuguang <at> gmail.com> wrote:
> Backup, auto-save, and lockfiles has been disabled in .dir-locals
> 
> ((nil
>   (make-backup-files . nil)
>   (create-lockfiles  . nil)
>   (auto-save-default . nil)
>   (auto-save-timeout . 10000)
>   ))
> 
> Best Regards,
> Shuguang

Did you try setting auto-save-interval to a large value, in addition to above?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Mon, 25 Dec 2017 12:30:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Mon, 25 Dec 2017 14:42:02 GMT) Full text and rfc822 format available.

Message #17 received at 29846 <at> debbugs.gnu.org (full text, mbox):

From: Shuguang Sun <shuguang <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 29846 <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
Subject: Re: bug#29846: scroll and fontify takes longer time for file in slow
 network
Date: Mon, 25 Dec 2017 22:41:51 +0800
[Message part 1 (text/plain, inline)]
>
> Did you try setting auto-save-interval to a large value, in addition to
> above?
>

No difference.
Otherwise, it will not get smoothly to scroll back to those has been viewed
/ fontified.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Mon, 25 Dec 2017 14:43:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Mon, 25 Dec 2017 16:49:01 GMT) Full text and rfc822 format available.

Message #23 received at 29846 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Shuguang Sun <shuguang <at> gmail.com>
Cc: 29846 <at> debbugs.gnu.org
Subject: Re: bug#29846: scroll and fontify takes longer time for file in slow
 network
Date: Mon, 25 Dec 2017 18:48:18 +0200
> From: Shuguang Sun <shuguang <at> gmail.com>
> Date: Mon, 25 Dec 2017 17:47:52 +0800
> 
> Backup, auto-save, and lockfiles has been disabled in .dir-locals
> 
> ((nil
>   (make-backup-files . nil)
>   (create-lockfiles  . nil)
>   (auto-save-default . nil)
>   (auto-save-timeout . 10000)
>   ))

You've disabled file locking, but Emacs still checks whether some
other Emacs session locked the file.  It does that as part of
restore-buffer-modified-p, which is called by JIT font-lock (because
fontification makes the buffer modified and JIT font-lock needs to
undo that after it fontifies a chunk of buffer).  Checking whether a
file is locked entails calling unlock_file, which in turn calls
read_lock_data, which tries to open the lock file.  I'm guessing that
this is slow on that remote volume of yours.

Maybe we should support a special value of create-lockfiles which
would mean don't create lockfiles and don't test fro lockfiles created
by other Emacs sessions.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Tue, 26 Dec 2017 01:05:01 GMT) Full text and rfc822 format available.

Message #26 received at 29846 <at> debbugs.gnu.org (full text, mbox):

From: Shuguang Sun <shuguang <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 29846 <at> debbugs.gnu.org
Subject: Re: bug#29846: scroll and fontify takes longer time for file in slow
 network
Date: Tue, 26 Dec 2017 09:04:32 +0800
[Message part 1 (text/plain, inline)]
On Tue, Dec 26, 2017 at 12:48 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Shuguang Sun <shuguang <at> gmail.com>
> > Date: Mon, 25 Dec 2017 17:47:52 +0800
> >
> > Backup, auto-save, and lockfiles has been disabled in .dir-locals
> >
> > ((nil
> >   (make-backup-files . nil)
> >   (create-lockfiles  . nil)
> >   (auto-save-default . nil)
> >   (auto-save-timeout . 10000)
> >   ))
>
> You've disabled file locking, but Emacs still checks whether some
> other Emacs session locked the file.  It does that as part of
> restore-buffer-modified-p, which is called by JIT font-lock (because
> fontification makes the buffer modified and JIT font-lock needs to
> undo that after it fontifies a chunk of buffer).  Checking whether a
> file is locked entails calling unlock_file, which in turn calls
> read_lock_data, which tries to open the lock file.  I'm guessing that
> this is slow on that remote volume of yours.
>
> Maybe we should support a special value of create-lockfiles which
> would mean don't create lockfiles and don't test fro lockfiles created
> by other Emacs sessions.
>

It makes sense. It has a short delayed reponse when I start to modify the
buffer (input, delete, etc.).
It will help single user if we can have a special value of create-lockfiles.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Wed, 27 Dec 2017 20:50:02 GMT) Full text and rfc822 format available.

Message #29 received at 29846 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Shuguang Sun <shuguang <at> gmail.com>
Cc: 29846 <at> debbugs.gnu.org
Subject: Re: bug#29846: scroll and fontify takes longer time for file in slow
 network
Date: Wed, 27 Dec 2017 15:49:56 -0500
> I have remote drive (//server/path) mapped to my windows system (samba?).
> The network is slow, and it takes some time to open the file. However,
> after I have the file opened and scroll down, it takes a long time to
> scroll to the next screen. It gets worse if the jit-lock-debug-mode is on.
> After that if I try to scroll back to those has been fontified, it get
> fluent as expected.

I believe this bug was introduced by yours truly
in commit 6bc76cee212aab0a2c02f8c28213fc842cc7880f:

  Author: Stefan Monnier <monnier <at> iro.umontreal.ca>
  Date:   Tue Apr 8 21:48:07 2014 -0400

    * src/insdel.c (prepare_to_modify_buffer_1): Cancel lock-file checks and
    region handling (and don't call signal_before_change) if
    inhibit_modification_hooks is set.
    (signal_before_change): Don't check inhibit_modification_hooks any more.
    * lisp/subr.el (with-silent-modifications): Don't bind deactivate-mark,
    buffer-file-name, and buffer-file-truename any more.

And I think the patch below hence belongs in emacs-26.  Any objection?


        Stefan


diff --git a/src/buffer.c b/src/buffer.c
index 75cb470af8..f518e72f9e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1346,7 +1346,6 @@ It is not ensured that mode lines will be updated to show the modified
 state of the current buffer.  Use with care.  */)
   (Lisp_Object flag)
 {
-  Lisp_Object fn;
 
   /* If buffer becoming modified, lock the file.
      If buffer becoming unmodified, unlock the file.  */
@@ -1355,15 +1354,18 @@ state of the current buffer.  Use with care.  */)
     ? current_buffer->base_buffer
     : current_buffer;
 
-  fn = BVAR (b, file_truename);
-  /* Test buffer-file-name so that binding it to nil is effective.  */
-  if (!NILP (fn) && ! NILP (BVAR (b, filename)))
+  if (!inhibit_modification_hooks)
     {
-      bool already = SAVE_MODIFF < MODIFF;
-      if (!already && !NILP (flag))
-	lock_file (fn);
-      else if (already && NILP (flag))
-	unlock_file (fn);
+      Lisp_Object fn = BVAR (b, file_truename);
+      /* Test buffer-file-name so that binding it to nil is effective.  */
+      if (!NILP (fn) && ! NILP (BVAR (b, filename)))
+        {
+          bool already = SAVE_MODIFF < MODIFF;
+          if (!already && !NILP (flag))
+	    lock_file (fn);
+          else if (already && NILP (flag))
+	    unlock_file (fn);
+        }
     }
 
   /* Here we have a problem.  SAVE_MODIFF is used here to encode




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29846; Package emacs. (Thu, 28 Dec 2017 16:22:01 GMT) Full text and rfc822 format available.

Message #32 received at 29846 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 29846 <at> debbugs.gnu.org, shuguang <at> gmail.com
Subject: Re: bug#29846: scroll and fontify takes longer time for file in slow
 network
Date: Thu, 28 Dec 2017 18:21:52 +0200
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> Date: Wed, 27 Dec 2017 15:49:56 -0500
> Cc: 29846 <at> debbugs.gnu.org
> 
> > I have remote drive (//server/path) mapped to my windows system (samba?).
> > The network is slow, and it takes some time to open the file. However,
> > after I have the file opened and scroll down, it takes a long time to
> > scroll to the next screen. It gets worse if the jit-lock-debug-mode is on.
> > After that if I try to scroll back to those has been fontified, it get
> > fluent as expected.
> 
> I believe this bug was introduced by yours truly
> in commit 6bc76cee212aab0a2c02f8c28213fc842cc7880f:
> 
>   Author: Stefan Monnier <monnier <at> iro.umontreal.ca>
>   Date:   Tue Apr 8 21:48:07 2014 -0400
> 
>     * src/insdel.c (prepare_to_modify_buffer_1): Cancel lock-file checks and
>     region handling (and don't call signal_before_change) if
>     inhibit_modification_hooks is set.
>     (signal_before_change): Don't check inhibit_modification_hooks any more.
>     * lisp/subr.el (with-silent-modifications): Don't bind deactivate-mark,
>     buffer-file-name, and buffer-file-truename any more.
> 
> And I think the patch below hence belongs in emacs-26.  Any objection?

LGTM, please push to emacs-26.

Thanks.




Reply sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
You have taken responsibility. (Thu, 28 Dec 2017 19:04:02 GMT) Full text and rfc822 format available.

Notification sent to Shuguang Sun <shuguang <at> gmail.com>:
bug acknowledged by developer. (Thu, 28 Dec 2017 19:04:02 GMT) Full text and rfc822 format available.

Message #37 received at 29846-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 29846-done <at> debbugs.gnu.org
Subject: Re: bug#29846: scroll and fontify takes longer time for file in slow
 network
Date: Thu, 28 Dec 2017 14:03:47 -0500
>> I believe this bug was introduced by yours truly
>> in commit 6bc76cee212aab0a2c02f8c28213fc842cc7880f:
[...]
>> And I think the patch below hence belongs in emacs-26.  Any objection?
> LGTM, please push to emacs-26.

Installed,


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 26 Jan 2018 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 151 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.