* Re: Slow Info startup
2005-11-30 2:38 ` Chong Yidong
@ 2005-11-30 2:41 ` Chong Yidong
2005-11-30 2:48 ` Juri Linkov
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Chong Yidong @ 2005-11-30 2:41 UTC (permalink / raw)
Cc: emacs-devel
Gah... shouldn't have been sending emails while hacking on longlines.
Sorry about that, here's the real patch.
*** emacs/lisp/info.el.~1.463.~ 2005-11-29 15:07:25.000000000 -0500
--- emacs/lisp/info.el 2005-11-29 21:22:28.000000000 -0500
***************
*** 3800,3816 ****
(and (not (equal (match-string 4) ""))
(match-string 4))
(match-string 2)))))
! (file Info-current-file)
(hl Info-history-list)
res)
(if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
! (setq file (Info-find-file (match-string 1 node) t)
node (if (equal (match-string 2 node) "")
"Top"
(match-string 2 node))))
(while hl
(if (and (string-equal node (nth 1 (car hl)))
! (string-equal file (nth 0 (car hl))))
(setq res (car hl) hl nil)
(setq hl (cdr hl))))
res))) 'info-xref-visited 'info-xref))
--- 3800,3817 ----
(and (not (equal (match-string 4) ""))
(match-string 4))
(match-string 2)))))
! (file (file-name-nondirectory Info-current-file))
(hl Info-history-list)
res)
(if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
! (setq file (match-string 1 node)
node (if (equal (match-string 2 node) "")
"Top"
(match-string 2 node))))
(while hl
(if (and (string-equal node (nth 1 (car hl)))
! (string-equal file (file-name-nondirectory
! (nth 0 (car hl)))))
(setq res (car hl) hl nil)
(setq hl (cdr hl))))
res))) 'info-xref-visited 'info-xref))
***************
*** 3905,3921 ****
(let ((node (if (equal (match-string 3) "")
(match-string 1)
(match-string 3)))
! (file Info-current-file)
(hl Info-history-list)
res)
(if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
! (setq file (Info-find-file (match-string 1 node) t)
! node (if (equal (match-string 2 node) "")
"Top"
(match-string 2 node))))
(while hl
(if (and (string-equal node (nth 1 (car hl)))
! (string-equal file (nth 0 (car hl))))
(setq res (car hl) hl nil)
(setq hl (cdr hl))))
res))) 'info-xref-visited 'info-xref)))
--- 3906,3923 ----
(let ((node (if (equal (match-string 3) "")
(match-string 1)
(match-string 3)))
! (file (file-name-nondirectory Info-current-file))
(hl Info-history-list)
res)
(if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
! (setq file (match-string 1 node)
! node (if (equal (match-string 2 node) "")
"Top"
(match-string 2 node))))
(while hl
(if (and (string-equal node (nth 1 (car hl)))
! (string-equal file (file-name-nondirectory
! (nth 0 (car hl)))))
(setq res (car hl) hl nil)
(setq hl (cdr hl))))
res))) 'info-xref-visited 'info-xref)))
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Slow Info startup
2005-11-30 2:38 ` Chong Yidong
2005-11-30 2:41 ` Chong Yidong
@ 2005-11-30 2:48 ` Juri Linkov
2005-11-30 3:19 ` Katsumi Yamaoka
2005-12-01 6:05 ` Richard M. Stallman
3 siblings, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2005-11-30 2:48 UTC (permalink / raw)
Cc: yamaoka, emacs-devel
> The change was to correctly fontify Info buffers opened with
> Info-on-current-buffer. If we are willing to sacrifice a little
> correctness, there is one change that can speed things up. See the
> attached patch.
It seems this patch just reverts your changes in that part.
> The side-effect of this is that Info will fontify incorrectly in one
> corner case. This happens when you call Info-on-current-buffer on
> a file named (e.g.) "elisp" outside of Info-directory list, or
> a non-file buffer named "elisp". When you browse around, your Info
> history will be recorded as though you are visiting the real "elisp"
> info file, at /usr/share/info/elisp or wherever. If you later visit
> the "real" info file, those links will be fontified as "previously
> visited" links. Maybe that's an acceptable situation, however.
I think this is not a big issue. Another case where it might not
fontify correctly is when the user changes Info-directory-list so
xrefs to the manuals with the same name are fontified as xrefs to
the same manual. OTOH, with the old code in info.el, the user could
move the same manual to another directory in Info-directory-list and
still be able to see xrefs to the moved manual fontified correctly.
So the old "manual-name-based" code (instead of the new "file-name-based")
is not absolutely incorrect, and is much faster.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Slow Info startup
2005-11-30 2:38 ` Chong Yidong
2005-11-30 2:41 ` Chong Yidong
2005-11-30 2:48 ` Juri Linkov
@ 2005-11-30 3:19 ` Katsumi Yamaoka
2005-12-01 6:05 ` Richard M. Stallman
3 siblings, 0 replies; 10+ messages in thread
From: Katsumi Yamaoka @ 2005-11-30 3:19 UTC (permalink / raw)
Cc: emacs-devel
>>>>> In <878xv6zwqa.fsf@stupidchicken.com> Chong Yidong wrote:
> Katsumi Yamaoka <yamaoka@jpl.org> writes:
>> I have several Info directories specified to Info-directory-list
>> and there are a lot of entries in those dir files. Recently, I
>> found it takes a long time to start up Info. It is caused by
>> the change of Info-fontify-node made at 2005-11-25. Is there a
>> way to make it fast besides reducing Info-directory-list?
> The change was to correctly fontify Info buffers opened with
> Info-on-current-buffer. If we are willing to sacrifice a little
> correctness, there is one change that can speed things up. See the
> attached patch.
Thanks. I tried it and confirmed it makes the Info start fast
as before.
> The side-effect of this is that Info will fontify
> incorrectly in one corner case. This happens when you call
> Info-on-current-buffer on a file named (e.g.) "elisp" outside of
> Info-directory list, or a non-file buffer named "elisp". When you
> browse around, your Info history will be recorded as though you are
> visiting the real "elisp" info file, at /usr/share/info/elisp or
> wherever. If you later visit the "real" info file, those links will
> be fontified as "previously visited" links. Maybe that's an
> acceptable situation, however.
It seems ok if those "elisp"s are the same, if anything, that's
acceptable on me.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Slow Info startup
2005-11-30 2:38 ` Chong Yidong
` (2 preceding siblings ...)
2005-11-30 3:19 ` Katsumi Yamaoka
@ 2005-12-01 6:05 ` Richard M. Stallman
2005-12-01 21:47 ` Juri Linkov
3 siblings, 1 reply; 10+ messages in thread
From: Richard M. Stallman @ 2005-12-01 6:05 UTC (permalink / raw)
Cc: yamaoka, emacs-devel
When
you browse around, your Info history will be recorded as though
you are visiting the real "elisp" info file, at
/usr/share/info/elisp or wherever. If you later visit the "real"
info file, those links will be fontified as "previously visited"
links. Maybe that's an acceptable situation, however.
Maybe it is acceptable, but first, could you explain why you think
this is the best solution?
Why is removing the directory related to making this code faster?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Slow Info startup
2005-12-01 6:05 ` Richard M. Stallman
@ 2005-12-01 21:47 ` Juri Linkov
2005-12-01 22:46 ` Chong Yidong
2005-12-02 18:21 ` Richard M. Stallman
0 siblings, 2 replies; 10+ messages in thread
From: Juri Linkov @ 2005-12-01 21:47 UTC (permalink / raw)
Cc: cyd, yamaoka, emacs-devel
> When you browse around, your Info history will be recorded as
> though you are visiting the real "elisp" info file, at
> /usr/share/info/elisp or wherever. If you later visit the
> "real" info file, those links will be fontified as "previously
> visited" links. Maybe that's an acceptable situation, however.
>
> Maybe it is acceptable, but first, could you explain why you think
> this is the best solution?
>
> Why is removing the directory related to making this code faster?
The Info history contains absolute file names. Menu items and
cross-references contain only file names without directory part.
Info uses the history to decide how to fontify visited references:
if the file name (and node name) of a menu item or cross-reference
exists in the history then it is fontified with `info-xref-visited'.
The old code uses `file-name-nondirectory' to remove directory part
from absolute file names in the history before comparing them to the
name extracted from a menu item or cross-reference. The new code uses
`Info-find-file' to find the absolute file name of a menu item
or cross-reference before comparing it to absolute file names in
the history. `Info-find-file' is a quadratically slow function that
iterates over `Info-directory-list' and `Info-suffix-list' to find the
absolute Info file name. The `dir' node usually contains hundreds of
menu items with non-absolute file names in parens, so `Info-find-file'
gets called on each of them during fontification in the new code.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Slow Info startup
2005-12-01 21:47 ` Juri Linkov
@ 2005-12-01 22:46 ` Chong Yidong
2005-12-02 0:03 ` Juri Linkov
2005-12-02 18:21 ` Richard M. Stallman
1 sibling, 1 reply; 10+ messages in thread
From: Chong Yidong @ 2005-12-01 22:46 UTC (permalink / raw)
Cc: yamaoka, rms, emacs-devel
Juri Linkov <juri@jurta.org> writes:
> The old code uses `file-name-nondirectory' to remove directory part
> from absolute file names in the history before comparing them to the
> name extracted from a menu item or cross-reference. The new code uses
> `Info-find-file' to find the absolute file name of a menu item
> or cross-reference before comparing it to absolute file names in
> the history. `Info-find-file' is a quadratically slow function that
> iterates over `Info-directory-list' and `Info-suffix-list' to find the
> absolute Info file name. The `dir' node usually contains hundreds of
> menu items with non-absolute file names in parens, so `Info-find-file'
> gets called on each of them during fontification in the new code.
Actually, we only need to use file-name-nondirectory for Info node
names specifying other info files. This way, links within info files
will always be highlighted correctly, even for info session started
with Info-on-current-buffer (external links will still have the flaw
discussed previously).
*** emacs/lisp/info.el.~1.463.~ 2005-12-01 15:08:51.000000000 -0500
--- emacs/lisp/info.el 2005-12-01 17:36:50.000000000 -0500
***************
*** 3800,3819 ****
(and (not (equal (match-string 4) ""))
(match-string 4))
(match-string 2)))))
! (file Info-current-file)
(hl Info-history-list)
res)
! (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
! (setq file (Info-find-file (match-string 1 node) t)
! node (if (equal (match-string 2 node) "")
! "Top"
! (match-string 2 node))))
! (while hl
! (if (and (string-equal node (nth 1 (car hl)))
! (string-equal file (nth 0 (car hl))))
! (setq res (car hl) hl nil)
! (setq hl (cdr hl))))
! res))) 'info-xref-visited 'info-xref))
;; For multiline ref, unfontify newline and surrounding whitespace
(save-excursion
(goto-char rbeg)
--- 3800,3830 ----
(and (not (equal (match-string 4) ""))
(match-string 4))
(match-string 2)))))
! (external-link-p
! (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
! (file (if external-link-p
! (match-string 1 node)
! Info-current-file))
(hl Info-history-list)
res)
! (if external-link-p
! (progn
! (setq node (if (equal (match-string 2 node) "")
! "Top"
! (match-string 2 node)))
! (while hl
! (if (and (string-equal node (nth 1 (car hl)))
! (string-equal file
! (file-name-nondirectory
! (nth 0 (car hl)))))
! (setq res (car hl) hl nil)
! (setq hl (cdr hl)))))
! (while hl
! (if (and (string-equal node (nth 1 (car hl)))
! (string-equal file (nth 0 (car hl))))
! (setq res (car hl) hl nil)
! (setq hl (cdr hl)))))
! res))) 'info-xref-visited 'info-xref))
;; For multiline ref, unfontify newline and surrounding whitespace
(save-excursion
(goto-char rbeg)
***************
*** 3902,3923 ****
;; Display visited menu items in a different face
(if (and Info-fontify-visited-nodes
(save-match-data
! (let ((node (if (equal (match-string 3) "")
! (match-string 1)
! (match-string 3)))
! (file Info-current-file)
! (hl Info-history-list)
! res)
! (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
! (setq file (Info-find-file (match-string 1 node) t)
! node (if (equal (match-string 2 node) "")
! "Top"
! (match-string 2 node))))
! (while hl
! (if (and (string-equal node (nth 1 (car hl)))
! (string-equal file (nth 0 (car hl))))
! (setq res (car hl) hl nil)
! (setq hl (cdr hl))))
res))) 'info-xref-visited 'info-xref)))
(when (and not-fontified-p (memq Info-hide-note-references '(t hide)))
(put-text-property (match-beginning 2) (1- (match-end 6))
--- 3913,3945 ----
;; Display visited menu items in a different face
(if (and Info-fontify-visited-nodes
(save-match-data
! (let* ((node (if (equal (match-string 3) "")
! (match-string 1)
! (match-string 3)))
! (external-link-p
! (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
! (file (if external-link-p
! (match-string 1 node)
! Info-current-file))
! (hl Info-history-list)
! res)
! (if external-link-p
! (progn
! (setq node (if (equal (match-string 2 node) "")
! "Top"
! (match-string 2 node)))
! (while hl
! (if (and (string-equal node (nth 1 (car hl)))
! (string-equal file
! (file-name-nondirectory
! (nth 0 (car hl)))))
! (setq res (car hl) hl nil)
! (setq hl (cdr hl)))))
! (while hl
! (if (and (string-equal node (nth 1 (car hl)))
! (string-equal file (nth 0 (car hl))))
! (setq res (car hl) hl nil)
! (setq hl (cdr hl)))))
res))) 'info-xref-visited 'info-xref)))
(when (and not-fontified-p (memq Info-hide-note-references '(t hide)))
(put-text-property (match-beginning 2) (1- (match-end 6))
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Slow Info startup
2005-12-01 22:46 ` Chong Yidong
@ 2005-12-02 0:03 ` Juri Linkov
0 siblings, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2005-12-02 0:03 UTC (permalink / raw)
Cc: yamaoka, rms, emacs-devel
> Actually, we only need to use file-name-nondirectory for Info node
> names specifying other info files. This way, links within info files
> will always be highlighted correctly, even for info session started
> with Info-on-current-buffer (external links will still have the flaw
> discussed previously).
> [...]
> ! (external-link-p
> ! (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
> ! (file (if external-link-p
> ! (match-string 1 node)
You need `file-name-nondirectory' around `match-string' here (and in
another similar place below). But generally your patch should work
correctly for links in the same Info file, so I think it is a good
improvement. (And I'd prefer one loop with `if external-link-p' inside
for clarity, because two separate loops wouldn't get significant
speedup here).
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Slow Info startup
2005-12-01 21:47 ` Juri Linkov
2005-12-01 22:46 ` Chong Yidong
@ 2005-12-02 18:21 ` Richard M. Stallman
1 sibling, 0 replies; 10+ messages in thread
From: Richard M. Stallman @ 2005-12-02 18:21 UTC (permalink / raw)
Cc: cyd, yamaoka, emacs-devel
The old code uses `file-name-nondirectory' to remove directory part
from absolute file names in the history before comparing them to the
name extracted from a menu item or cross-reference.
In general, that could make a mistake.
The new code uses
`Info-find-file' to find the absolute file name of a menu item
or cross-reference before comparing it to absolute file names in
the history.
In general, that is more correct.
`Info-find-file' is a quadratically slow function that
iterates over `Info-directory-list' and `Info-suffix-list' to find the
absolute Info file name.
Indeed, this is slow. Would it solve the problem to maintain a cache
that records arguments that were given to Info-find-file together with
the results that were obtained?
Or is even one call for each file too slow?
Another idea: get the directory lists of the directories in
Info-directory-list. Then Info-find-file can do its work without
actually trying to open the files, by scanning those lists instead.
Maybe that would be both fast enough and 100% correct.
Yidong wrote:
Actually, we only need to use file-name-nondirectory for Info node
names specifying other info files. This way, links within info files
will always be highlighted correctly, even for info session started
with Info-on-current-buffer (external links will still have the flaw
discussed previously).
Both methods could be speeded up this way. If you use this technique
to optimize the Info-find-file method, does that make it fast enough?
^ permalink raw reply [flat|nested] 10+ messages in thread