unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: yyoncho <yyoncho@gmail.com>
Cc: sebastien@chapu.is, 31138@debbugs.gnu.org
Subject: bug#31138: Native json slower than json.el
Date: Tue, 26 Mar 2019 05:51:11 +0200	[thread overview]
Message-ID: <83a7himgy8.fsf@gnu.org> (raw)
In-Reply-To: <CACCVLQVJpju3guJ4FPVkzex6ek1u+=7Pdj343rnHEwNqN5uC0A@mail.gmail.com> (message from yyoncho on Mon, 25 Mar 2019 23:34:38 +0200)

> From: yyoncho <yyoncho@gmail.com>
> Date: Mon, 25 Mar 2019 23:34:38 +0200
> Cc: Sébastien Chapuis <sebastien@chapu.is>, 
> 	31138@debbugs.gnu.org
> 
>  You mean, in your setup it's twice slower than in "emacs -Q"?
>  
> Yes.

Then my suggestion to bisect your setup still stands.  Alternatively,
if you can find a recipe where this happens and post it, I will look
into it.

>  And you are saying that the changes I made have no effect on the
>  performance?  Then what about the 100-fold slowdown you were talking
>  about, allegedly caused by the hooks?
> 
> The slowdown caused by the hooks was caused by the C-g and the issue does not exist and it is fixed by
> your patch. Otherwise, it is ~0.6 vs ~1.2secs. 

For 10 benchmark runs?

And even if it's twice slower than "emacs -Q", it should be still
almost twice faster than the Lisp implementation, at least that's what
I see on 2 different machines with 2 different OSes.

>  > I believe that it is caused by code_convert_string .
> 
>  This needs some more specific explanation, because code_convert_string
>  is called in both your setup and in "emacs -Q".  So it isn't
>  code_convert_string itself, it's something else, perhaps triggered by
>  code_convert_string, like those hooks I disabled.
> 
> Yes, I think that it is related to switching to different buffers.

Then json-parse-buffer doesn't have this problem in your setup?

> 1. Now we know where to look for if we want to optimize further emacs -q parsing performance.

I'm not sure we know that.  We didn't analyze the profile below the
Lisp primitives level.  If we want to see what takes significant parts
of the time in the benchmark runs, we need to use perf and look at the
C level below the primitives

> 2. Now we know what the difference between emacs -q performance and my setup is caused by something in
> that function.

No, I don't think we know that.  You say above that it's caused by
switching buffers, which is not in code_convert_string.

> IMO the fix should go in

OK, will do.

> I summarized what are lsp-mode problems. 

What are they?  Can you summarize them again, please, or point me to
where you did so?

>  I feel that I no longer understand what problem we are trying to
>  solve, and that no matter what improvements I propose, the discussion
>  always ends up insisting that code_convert_string is the culprit.
> 
> ...and it actually *was* the culprit, right?

No, the culprit was the hooks we called as a side effect of that function.

> Furthermore, it the performance test that I mentioned proves it is
> *still* the culprit...

I'm sorry, but I don't see that proof.  Can you explain how you arrive
at that conclusion?

> Here it is the summary of the issues that I see in native json parsing from lsp-mode (beware that I will list
> issues that are not relevant to that bug bug#31138).
> 
> 1. Hooks might be triggered when performing json parsing(fixed by you). I hoped that this will fix 2) but
> apparently these are two separate issues. 

Agreed.  So the issue with hooks no longer exists (once the patch I
sent is committed).

> 2. There is a difference in performance between emacs -q and non-"emacs -q" . I would expect json parsing
> to be side effect free. (My guess is that it is related to switching buffers because with-temp-buffer has some
> positive effect).

I don't think I understand this.  What side effects are you talking
about?  Switching buffers is not part of json-parse-string.

> 3. Even in the best case scenario native parsing is not fast enough. In lsp-mode, you might receive 3.5mb
> json as a server-side response while you are typing. E. g. I might type "abc" and get 10.5 mb json. I compared
> the performance of nodejs parsing and it is ~10 times faster than emacs -q. 

10 times faster doesn't mean Emacs isn't "fast enough".  The current
native parsing is faster than what we had before in Lisp, so this is
progress.

And if we want to see how to optimize JSON parsing in Emacs even more,
we need to profile the code with a large enough JSON, and see what
takes the time.

> 4. JSON parsing can be performed only on the UI thread. 

You can do that in a separate thread in a module.

> Alternatively, we (lsp-mode team) will be able to solve all these in a dynamic module if emacs module
> mechanism is extended to allow creating emacs lisp structures efficiently. 

What is lacking in the modules mechanism?

> PS: I really enjoy the ironical passive-aggressive style of communication which I guess is common for
> emacs-devel but I will still be trying to be constructive. I just want you to know that I won't bother answering
> and focus only on the stuff that will help to solve the issue...

I actually think that discussions on emacs-devel, with a few
exceptions, are generally to the point and quite productive.





  parent reply	other threads:[~2019-03-26  3:51 UTC|newest]

Thread overview: 161+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-12 19:13 bug#31138: Native json slower than json.el Sebastien Chapuis
2018-04-13  7:24 ` Eli Zaretskii
2018-04-15 14:40   ` Sebastien Chapuis
2018-04-15 15:19     ` Eli Zaretskii
2019-03-23  1:59       ` Sébastien Chapuis
2019-03-23  8:15         ` Eli Zaretskii
2019-03-23  9:40           ` Eli Zaretskii
2019-03-23 12:59             ` Sébastien Chapuis
2019-03-23 13:21               ` Eli Zaretskii
2019-03-23 13:31                 ` yyoncho
2019-03-23 14:00                   ` Eli Zaretskii
2019-03-23 14:32                     ` yyoncho
2019-03-23 14:55                       ` Eli Zaretskii
2019-03-23 15:27                         ` yyoncho
2019-03-23 16:29                           ` Eli Zaretskii
     [not found]                             ` <CACCVLQW=_YngoTwXU+1BDvVVy5jwxSmDFUQJBvs8=PrP=fn=aw@mail.gmail.com>
2019-03-23 18:50                               ` Eli Zaretskii
2019-03-23 20:23                                 ` yyoncho
2019-03-23 20:54                                   ` Eli Zaretskii
2019-03-23 21:04                                     ` yyoncho
2019-03-24  3:32                                       ` Eli Zaretskii
2019-03-24  9:35                                         ` yyoncho
2019-03-24 11:20                                           ` Eli Zaretskii
2019-03-24 11:37                                             ` yyoncho
2019-03-24 15:15                                               ` Eli Zaretskii
2019-03-24 18:24                                                 ` yyoncho
2019-03-24 18:28                                                   ` Eli Zaretskii
2019-03-24 20:57                                                     ` yyoncho
2019-03-25  3:32                                                       ` Eli Zaretskii
2019-03-25  5:44                                                         ` yyoncho
2019-03-25 16:42                                                           ` Eli Zaretskii
2019-03-25 18:20                                                             ` yyoncho
2019-03-25 18:25                                                               ` Eli Zaretskii
2019-03-25 19:16                                                                 ` yyoncho
2019-03-25 20:05                                                                   ` Eli Zaretskii
2019-03-25 21:34                                                                     ` yyoncho
2019-03-25 23:04                                                                       ` Dmitry Gutov
2019-03-26  3:51                                                                       ` Eli Zaretskii [this message]
2019-03-26 16:14                                                                       ` Eli Zaretskii
2019-03-26 17:45                                                                         ` yyoncho
2019-03-26 18:11                                                                           ` Eli Zaretskii
2019-03-26 18:15                                                                             ` yyoncho
2019-04-16  1:36                                                                         ` Dmitry Gutov
2019-04-16  2:38                                                                           ` Eli Zaretskii
2019-04-16 13:50                                                                             ` Dmitry Gutov
2019-04-16 15:13                                                                               ` Eli Zaretskii
2019-04-16 15:30                                                                                 ` Dmitry Gutov
2019-04-16 16:10                                                                                   ` Eli Zaretskii
2019-04-16 16:23                                                                                     ` Dmitry Gutov
2019-04-16 16:44                                                                                       ` Eli Zaretskii
2019-04-21  8:58                                                                                         ` Eli Zaretskii
2019-04-21  9:15                                                                                           ` Dmitry Gutov
2019-04-21  9:31                                                                                             ` Eli Zaretskii
2019-04-21 10:23                                                                                               ` yyoncho
2019-04-21 10:37                                                                                                 ` Eli Zaretskii
2019-04-21 11:38                                                                                                   ` yyoncho
2019-04-21 12:15                                                                                                     ` Eli Zaretskii
2019-04-21 13:28                                                                                                       ` yyoncho
2019-04-21 19:03                                                                                                         ` Eli Zaretskii
2019-04-21 20:13                                                                                                           ` Eli Zaretskii
2019-04-22  5:38                                                                                                           ` yyoncho
2019-04-22  8:01                                                                                                             ` Eli Zaretskii
2019-04-22 13:00                                                                                                               ` yyoncho
2019-04-22 13:17                                                                                                                 ` Eli Zaretskii
2019-04-22 16:53                                                                                                                   ` Ivan
2019-04-22 16:58                                                                                                                     ` Eli Zaretskii
2019-04-21 22:17                                                                                                       ` Dmitry Gutov
2019-04-22  7:16                                                                                                         ` Eli Zaretskii
2019-04-22 13:54                                                                                                           ` Dmitry Gutov
2019-04-22 15:24                                                                                                             ` Eli Zaretskii
2019-04-22 15:31                                                                                                               ` Dmitry Gutov
2019-04-21 12:59                                                                                                 ` Philipp Stephani
2019-04-21 13:09                                                                                                   ` yyoncho
2019-04-21 13:33                                                                                                     ` Philipp Stephani
2019-04-22 11:48                                                                                                       ` Dmitry Gutov
2019-04-22 12:12                                                                                                         ` Eli Zaretskii
2019-04-22 12:24                                                                                                           ` Dmitry Gutov
2019-04-22 13:02                                                                                                             ` Eli Zaretskii
2019-04-22 15:02                                                                                                               ` Dmitry Gutov
2019-04-22 15:36                                                                                                                 ` Eli Zaretskii
2019-04-22 16:16                                                                                                                   ` Dmitry Gutov
2019-04-22 16:28                                                                                                                     ` Eli Zaretskii
2019-04-22 16:44                                                                                                                       ` Dmitry Gutov
2019-04-22 16:50                                                                                                                         ` Eli Zaretskii
2019-04-22 17:05                                                                                                                       ` Dmitry Gutov
2019-04-22 17:24                                                                                                                         ` Eli Zaretskii
2019-04-22 21:03                                                                                                                           ` Dmitry Gutov
2019-04-23 10:22                                                                                                                             ` Eli Zaretskii
2019-04-23 11:39                                                                                                                               ` Dmitry Gutov
2019-04-23 13:19                                                                                                                                 ` Eli Zaretskii
2019-04-22 16:49                                                                                                                     ` Eli Zaretskii
2019-04-22 17:11                                                                                                                       ` Dmitry Gutov
2019-04-22 17:26                                                                                                                         ` Eli Zaretskii
2019-04-22 22:23                                                                                                                           ` Dmitry Gutov
2019-04-23  6:00                                                                                                                             ` Eli Zaretskii
2019-04-23  9:46                                                                                                                               ` Philipp Stephani
2019-04-23 10:38                                                                                                                                 ` Eli Zaretskii
2019-04-23 10:44                                                                                                                                   ` Dmitry Gutov
2019-04-24  2:23                                                                                                                               ` Richard Stallman
2019-04-22 17:12                                                                                                                       ` Eli Zaretskii
2019-04-22 21:00                                                                                                                         ` Dmitry Gutov
2019-04-21 22:14                                                                                                 ` Dmitry Gutov
2019-04-22  7:06                                                                                                   ` Eli Zaretskii
2019-04-21 22:12                                                                                               ` Dmitry Gutov
2019-04-22  7:03                                                                                                 ` Eli Zaretskii
2019-04-22 11:46                                                                                                   ` Dmitry Gutov
2019-04-22 12:07                                                                                                     ` Eli Zaretskii
2019-04-22 12:58                                                                                                       ` Dmitry Gutov
2019-04-22 13:12                                                                                                         ` Eli Zaretskii
2019-04-22 13:58                                                                                                           ` Dmitry Gutov
2019-04-22 15:25                                                                                                             ` Eli Zaretskii
2019-04-22 15:41                                                                                                               ` Dmitry Gutov
2019-04-22 15:50                                                                                                                 ` Eli Zaretskii
2019-04-22 16:00                                                                                                                   ` Dmitry Gutov
2019-04-22 16:22                                                                                                                     ` Eli Zaretskii
2019-04-22 19:55                                                                                                                       ` Dmitry Gutov
2019-04-22 20:28                                                                                                                         ` Eli Zaretskii
2019-04-23 11:52                                                                                                                           ` Dmitry Gutov
2019-04-23 12:15                                                                                                                             ` Eli Zaretskii
2019-04-23 12:37                                                                                                                               ` yyoncho
2019-04-23 13:09                                                                                                                                 ` Eli Zaretskii
2019-04-23 13:27                                                                                                                                   ` yyoncho
2019-04-23 14:24                                                                                                                                     ` Eli Zaretskii
2019-04-23 12:37                                                                                                                               ` Sébastien Chapuis
2019-04-23 13:10                                                                                                                                 ` Eli Zaretskii
2019-04-23 14:22                                                                                                                               ` Dmitry Gutov
2019-04-23 14:40                                                                                                                                 ` Philipp Stephani
2019-04-23 15:09                                                                                                                                   ` Eli Zaretskii
2019-04-23 15:17                                                                                                                                     ` Eli Zaretskii
2019-04-23 15:36                                                                                                                                     ` yyoncho
2019-04-23 15:39                                                                                                                                       ` Eli Zaretskii
2019-04-23 15:43                                                                                                                                         ` yyoncho
2019-04-23 22:34                                                                                                                                     ` Dmitry Gutov
2019-04-24  6:20                                                                                                                                       ` Eli Zaretskii
2019-04-24  6:57                                                                                                                                         ` Dmitry Gutov
2019-04-24  7:28                                                                                                                                           ` Eli Zaretskii
2019-04-24  9:52                                                                                                                                             ` Dmitry Gutov
2019-04-23 14:58                                                                                                                                 ` Eli Zaretskii
2019-04-24 15:55                                                                                                                                   ` Dmitry Gutov
2019-04-24 16:21                                                                                                                                     ` Eli Zaretskii
2019-04-24 16:46                                                                                                                                       ` Dmitry Gutov
2019-04-24 17:06                                                                                                                                         ` Eli Zaretskii
2019-04-24 17:36                                                                                                                                           ` Dmitry Gutov
2019-04-24 17:43                                                                                                                                             ` Eli Zaretskii
2019-04-24 20:25                                                                                                                                               ` Dmitry Gutov
2019-04-25 10:44                                                                                                                                                 ` Eli Zaretskii
2019-04-25 14:27                                                                                                                                                   ` Dmitry Gutov
2020-08-22 23:28                                                                                                                                                     ` Lars Ingebrigtsen
2020-08-23  5:50                                                                                                                                                       ` Eli Zaretskii
2019-04-23 14:50                                                                                                                               ` Andy Moreton
2019-04-23 15:03                                                                                                                                 ` Eli Zaretskii
2019-04-23 15:44                                                                                                                                   ` Andy Moreton
2019-04-22 11:36                                                                                                 ` Dmitry Gutov
2019-04-22 12:01                                                                                                   ` Eli Zaretskii
2019-04-22 13:11                                                                                                     ` Dmitry Gutov
2019-03-30  9:07                                                               ` Eli Zaretskii
2019-04-22 18:20 ` Alex Gramiak
2019-04-22 18:27   ` Eli Zaretskii
2019-04-22 19:52     ` Alex Gramiak
2019-04-22 20:05       ` Dmitry Gutov
2019-04-23  3:06         ` Alex Gramiak
2019-04-23 11:44           ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83a7himgy8.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=31138@debbugs.gnu.org \
    --cc=sebastien@chapu.is \
    --cc=yyoncho@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).