[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25122: 24.5; function describe-variable hangs on large variables
From: |
npostavs |
Subject: |
bug#25122: 24.5; function describe-variable hangs on large variables |
Date: |
Sun, 12 Mar 2017 12:07:43 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> npostavs@users.sourceforge.net writes:
>
>> I've been attempting an alternate approach which prettyprints the object
>> while scanning it instead of the current way of printing and then
>> reindenting. Without optimizing, it's about 3 times as fast as the
>> current pp (it's the pp-prin1 in the benchmarks below), though more than
>> 3 times slower than your mapc pp trick. On the other hand, it also
>> doesn't yet handle function-specific indentation or any compound
>> structure apart from lists, so I'm not sure if it will end up being much
>> faster.
>>
>> (benchmark 1 '(with-temp-buffer (pp-prin1 long-list (current-buffer)) nil))
>> "Elapsed time: 3.391232s (0.565806s in 11 GCs)"
>> (benchmark 1 '(progn (pp-to-string long-list) nil))
>> "Elapsed time: 9.988515s (0.148034s in 3 GCs)"
>> (benchmark 1 '(progn (with-output-to-string (mapc 'pp long-list)) nil))
>> "Elapsed time: 0.983493s (0.144424s in 3 GCs)"
>> (benchmark 1 '(progn (cl-prin1-to-string long-list) nil))
>> "Elapsed time: 0.511617s (0.152483s in 3 GCs)"
>> (benchmark 1 '(progn (prin1-to-string long-list) nil))
>> "Elapsed time: 0.029320s"
>
> Interesting, thanks to work on this.
With a couple of minor optimizations it's down to about 1.8s. The first
is to reuse the tempbuffer instead of letting cl-prin1-to-string make a
new one each time. Second is to add
(eval-when-compile
(cl-proclaim '(optimize (speed 3) (safety 0))))
This also stops these warnings (I guess they're caused by the "safety" code?):
../../emacs-master/lisp/emacs-lisp/pp.el:159:19:Warning: value returned from
(aref state 6) is unused
../../emacs-master/lisp/emacs-lisp/pp.el:204:24:Warning: value returned from
(aref state 10) is unused
New times:
(benchmark 1 '(with-temp-buffer (pp-prin1 long-list (current-buffer)) nil))
"Elapsed time: 1.800146s (0.231706s in 6 GCs)"
(benchmark 1 '(progn (pp-to-string long-list) nil))
"Elapsed time: 9.950225s (0.154100s in 4 GCs)"
(benchmark 1 '(progn (with-output-to-string (mapc 'pp long-list)) nil))
"Elapsed time: 0.980923s (0.149787s in 4 GCs)"
I foolishly neglected to write down what exactly long-list was before,
starting from emacs -Q this seems to approximate it though:
(progn (require 'pp)
(require 'dabbrev)
(require 'edebug)
(require 'cc-mode)
(require 'vc)
(setq long-list load-history)
(length long-list)) ;=> 142
v2-0001-New-pretty-printer-Bug-25122.patch
Description: patch
- bug#25122: 24.5; function describe-variable hangs on large variables, (continued)
- bug#25122: 24.5; function describe-variable hangs on large variables, Thierry Volpiatto, 2017/03/12
- bug#25122: 24.5; function describe-variable hangs on large variables, Stefan Monnier, 2017/03/12
- bug#25122: 24.5; function describe-variable hangs on large variables, npostavs, 2017/03/12
- bug#25122: 24.5; function describe-variable hangs on large variables, Drew Adams, 2017/03/12
- bug#25122: 24.5; function describe-variable hangs on large variables, Stefan Monnier, 2017/03/12
- bug#25122: 24.5; function describe-variable hangs on large variables, npostavs, 2017/03/12
- bug#25122: 24.5; function describe-variable hangs on large variables, npostavs, 2017/03/13
- bug#25122: 24.5; function describe-variable hangs on large variables, npostavs, 2017/03/13
- bug#25122: 24.5; function describe-variable hangs on large variables, npostavs, 2017/03/15
bug#25122: 24.5; function describe-variable hangs on large variables, Thierry Volpiatto, 2017/03/11
- bug#25122: 24.5; function describe-variable hangs on large variables,
npostavs <=
bug#25122: 24.5; function describe-variable hangs on large variables, Stefan Monnier, 2017/03/11