[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#31138: Native json slower than json.el
From: |
Sébastien Chapuis |
Subject: |
bug#31138: Native json slower than json.el |
Date: |
Sat, 23 Mar 2019 20:59:46 +0800 |
Sorry for not being clear, my main concern was the difference when
wrapping json-parse-string with with-temp-buffer or not.
You are right, I tested with the current master branch and it is
faster (emacs -Q):
(with-current-buffer "large.json"
(benchmark-run 10 (json-parse-string (buffer-string))))
;;; (1.45898128 10 0.15294547200000003)
(with-current-buffer "large.json"
(let ((str (buffer-string)))
(benchmark-run 10 (with-temp-buffer (json-parse-string str)))))
;;; (0.706171416 10 0.18795709700000002)
(with-current-buffer "large.json"
(let ((str (buffer-string)))
(benchmark-run 10 (with-temp-buffer (json-read-from-string str)))))
;;; (2.476727624 138 1.5660531400000006)
I have tested to read the file literally, as you suggested and there
is now no difference with or without with-temp-buffer (emacs -Q):
(with-current-buffer (find-file-noselect "large.json" nil t)
(benchmark-run 10 (json-parse-string (buffer-string))))
;;; (0.7011264119999999 10 0.118889765)
(with-current-buffer (find-file-noselect "large.json" nil t)
(let ((str (buffer-string)))
(benchmark-run 10 (with-temp-buffer (json-parse-string str)))))
;;; (0.7159130309999999 10 0.15112133999999997)
For the context, with lsp-mode, we have users complaining about
performance of json-parse-string [1].
Some have found out that the function is way faster with emacs -Q but
it is "dead slow" with their Spacemacs setup.
In lsp-mode, we are reading child process output by calling
`make-process` with `:coding 'no-conversion`, I think it has the same
behavior than reading a file "literally" ?
Is there anything else we could do to improve the performance from
reading the process output ?
Now the problem is how can we have the same performance with a regular
emacs setup than with emacs -Q ?
With my emacs setup, I have this result:
(with-current-buffer (find-file-noselect "large.json" nil t)
(benchmark-run 10 (json-parse-string (buffer-string))))
;;; (1.515018996 10 0.5256668049999996)
(with-current-buffer (find-file-noselect "large.json" nil t)
(let ((str (buffer-string)))
(benchmark-run 10 (with-temp-buffer (json-parse-string str)))))
;;; (1.156755376 10 0.5596599300000001)
This is almost 2x slower than with emacs -Q.
Note that there is still a difference with and without `with-temp-buffer`.
What can we do to reach emacs -Q performance ?
Thanks for your time,
Sebastien Chapuis
[1] https://github.com/emacs-lsp/lsp-mode/issues/210#issuecomment-471314904
Le sam. 23 mars 2019 à 17:40, Eli Zaretskii <eliz@gnu.org> a écrit :
>
> > Date: Sat, 23 Mar 2019 10:15:26 +0200
> > From: Eli Zaretskii <eliz@gnu.org>
> > Cc: yyoncho@gmail.com, 31138@debbugs.gnu.org
> >
> > So on my system the native JSON support does this job about 4 times
> > faster than the Lisp implementation. I see the same ratio of 4
> > consistently in both optimized and unoptimized builds of Emacs (the
> > above numbers are from an optimized build).
>
> I've just tried on another system, and there I get the native JSON
> support 3 times faster than json.el.
- bug#31138: Native json slower than json.el, Sébastien Chapuis, 2019/03/22
- bug#31138: Native json slower than json.el, Eli Zaretskii, 2019/03/23
- bug#31138: Native json slower than json.el, Eli Zaretskii, 2019/03/23
- bug#31138: Native json slower than json.el,
Sébastien Chapuis <=
- bug#31138: Native json slower than json.el, Eli Zaretskii, 2019/03/23
- bug#31138: Native json slower than json.el, yyoncho, 2019/03/23
- bug#31138: Native json slower than json.el, Eli Zaretskii, 2019/03/23
- bug#31138: Native json slower than json.el, yyoncho, 2019/03/23
- bug#31138: Native json slower than json.el, Eli Zaretskii, 2019/03/23
- bug#31138: Native json slower than json.el, yyoncho, 2019/03/23
- bug#31138: Native json slower than json.el, Eli Zaretskii, 2019/03/23
- Message not available
- bug#31138: Native json slower than json.el, Eli Zaretskii, 2019/03/23
- bug#31138: Native json slower than json.el, yyoncho, 2019/03/23
- bug#31138: Native json slower than json.el, Eli Zaretskii, 2019/03/23