From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: yyoncho Newsgroups: gmane.emacs.bugs Subject: bug#31138: Native json slower than json.el Date: Sat, 23 Mar 2019 16:32:48 +0200 Message-ID: References: <87sh806xwa.fsf@chapu.is> <834lkf7ely.fsf@gnu.org> <878t9own1p.fsf@chapu.is> <838t9o4hvl.fsf@gnu.org> <83r2ayovkx.fsf@gnu.org> <83pnqiormy.fsf@gnu.org> <83lg15pvzr.fsf@gnu.org> <83k1gppu73.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000001bac640584c3d9cf" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="177294"; mail-complaints-to="usenet@blaine.gmane.org" Cc: =?UTF-8?Q?S=C3=A9bastien?= Chapuis , 31138@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 23 17:03:41 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7j7V-000jyg-Dh for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Mar 2019 17:03:41 +0100 Original-Received: from localhost ([127.0.0.1]:45129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7j7U-0003dq-B1 for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Mar 2019 12:03:40 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7j7B-0003Tr-Qv for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2019 12:03:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7iz8-0004G1-Ke for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2019 11:55:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42167) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h7iz8-0004Fk-Fo for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2019 11:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h7iz8-000796-EL for bug-gnu-emacs@gnu.org; Sat, 23 Mar 2019 11:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: yyoncho Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Mar 2019 15:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31138 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 31138-submit@debbugs.gnu.org id=B31138.155335645327390 (code B ref 31138); Sat, 23 Mar 2019 15:55:02 +0000 Original-Received: (at 31138) by debbugs.gnu.org; 23 Mar 2019 15:54:13 +0000 Original-Received: from localhost ([127.0.0.1]:55708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h7iyL-00077a-5c for submit@debbugs.gnu.org; Sat, 23 Mar 2019 11:54:13 -0400 Original-Received: from mail-qk1-f196.google.com ([209.85.222.196]:38379) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h7hhp-0005CE-8P for 31138@debbugs.gnu.org; Sat, 23 Mar 2019 10:33:06 -0400 Original-Received: by mail-qk1-f196.google.com with SMTP id g1so2916627qki.5 for <31138@debbugs.gnu.org>; Sat, 23 Mar 2019 07:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZBIFVYgM4wSRBaFoWdnvX16V7PlyiK8MXwURMEVV3Kk=; b=UNQOoWcl4jp08+pVlU2x7m7dZy0ksGwBYloBlU9x7+/Ch72DLFivS7mB9E6OCEAYiS j29bBbUOk0Z6VXpS7YPOV1TJLCzCUw8Jd6XlF0WrqJu/pIuF5vGS9i9ITYnKPO7kqJR9 k1Z/41Z4SrkZmacKS0jyl8N1qVXL3baQRAL24FASYZmLJhiwGbdemgRw0NZSFK/Tne1b 3d/XaKkmD9/EU/7xG/6FNcdBv60QsOeqsQzAztOag62eeALaEAaaPdfiksCeMqh9tiuA O//nMhw/IwpckrTvWRWMDdARglov6YlACI1X+LFY2hMKZsBp6Q/vEIw82Qqyq7SbDUDe 574A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZBIFVYgM4wSRBaFoWdnvX16V7PlyiK8MXwURMEVV3Kk=; b=rjz/rLh9qjpqDOD2rGGbGgF8kYCJLsKzPYRNPKGBo9BunwxO95UfPmvSP/QQOaEBiA 0XiTqvaO4a7dFVlKTXW4uJ3eP8QCCnJJOguCVm5YY+mWRle5W5D8fp0J58Il2N0+sLk4 m4t2Bjhry+u3Wg0J1VUKQXTetk651EmkxHefVsFPQnBLu49qfAK0Q3LGFFLGFw/84/fb BQQ6bKGR6pWR4uN5x3cniCYkTUh7IBIS05kILd4H4su6d+slZGtytafDZeGgV0qbCu5v TK+KpkK4iadcedUpPiRRbnfm5uPoRde19i5B8j2r2R5dsSCX3gDu30u+C0QbnrImH5dA 5SsA== X-Gm-Message-State: APjAAAXKNCyIoEfxBcEfNQIGNQ7RQG87TKnTlkekOUz11hrFvvYx2FD8 ib1BAPqeBXKL96N1oJLNpka/mJNtZYQjgkPcvTY= X-Google-Smtp-Source: APXvYqzWBFxIRELXVkAe2kj0xsYA4km2yf1pY1tkMecOJDVl6mWgKf3m8ONL7LlagGeFrAyLgMDsH9DT96PsSLho3K0= X-Received: by 2002:ae9:ef94:: with SMTP id d142mr6090030qkg.350.1553351579510; Sat, 23 Mar 2019 07:32:59 -0700 (PDT) In-Reply-To: <83k1gppu73.fsf@gnu.org> X-Mailman-Approved-At: Sat, 23 Mar 2019 11:54:11 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:156669 Archived-At: --0000000000001bac640584c3d9cf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Eli, Sorry for being unclear: Here it is a summary of the gist from the previous mail is doing: 1. Prepare json string to parse 2. Set counter my/call-counter to 0 3. Create function my/test-query-function which will increase the counter. 4. Add this function to 'kill-buffer-query-functions. 5. Parse the string from 1). using json-parse-string 6. At this point, my/call-counter is 32982 which means that json-parse-string has triggered 32982 calls to my/test-query-function . I would add also that the number of strings in the json file that I am using is exactly 32982 so I suspect that the issue is related to json_make_string . Here it is the output of from single invocation of json-parse-string - https://gist.github.com/yyoncho/101a87260b407d9f327b24c72ab15a92 - as you can see there are numerous elisp functions invoked under json-parse-string. What I am unable to provide is a minimal example so you could reproduce this behaviour on your side using emacs -Q. Thanks, Ivan On Sat, Mar 23, 2019 at 4:00 PM Eli Zaretskii wrote: > > From: yyoncho > > Date: Sat, 23 Mar 2019 15:31:39 +0200 > > Cc: S=C3=A9bastien Chapuis , > > 31138@debbugs.gnu.org > > > > Take a look at the following piece of code: > > > > https://gist.github.com/yyoncho/9e9c4e14734fdd9a22d6600a88a27ae1 > > (with the latest emacs compiled from master) > > OK. > > > Unfortunately, I wasn't unable to reproduce the behaviour with "emacs > -q" and even it does not reproduce > > right after I load my emacs configuration but after doing some > navigation/coding. > > Sorry, I don't think I understand what behavior you were unable to > reproduce. Please elaborate. > > > I believe that native parsing is > > calling some function list defined in the elisp space but I am unable t= o > track down this. > > Maybe so, but I don't think I see a Lisp function called from json.c code= . > > > Please, let me know what I can do to help to diagnose this issue. > > Are we still talking about too-slow performance of json-parse-string? > If so, and if you think some Lisp code is responsible for that, then > running your benchmark test under profiler.el would be the first thing > I'd suggest. > --0000000000001bac640584c3d9cf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Eli,

Sorry for being unclear:
Here it is a summary of the gist from the previous mail is doin= g:

1. Prepare json string to parse
2. Se= t counter my/call-counter to 0
3. Create function=C2=A0my/test-qu= ery-function which will increase the counter.
4. Add this functio= n to 'kill-buffer-query-functions.
5. Parse the string from 1= ). using json-parse-string
6. At this point, my/call-counter is 3= 2982 which means that json-parse-string has triggered 32982 calls to my/tes= t-query-function .=C2=A0I would add also that the number of strings in the = json=C2=A0file that I am using is exactly=C2=A032982 so I suspect that the = issue is related to=C2=A0json_make_string .

Here i= t is the output of from single invocation of json-parse-string -=C2=A0htt= ps://gist.github.com/yyoncho/101a87260b407d9f327b24c72ab15a92 - as you = can see there are numerous elisp functions invoked under json-parse-string.= =C2=A0

What I am unable to provide is a minimal ex= ample so you could reproduce this behaviour on your side using emacs -Q.=C2= =A0

Thanks,
Ivan
=

On Sat, Mar 23, 2019 at 4:00 PM Eli Zaretskii <eliz@gnu.org> wrote:
> From: yyoncho <yyoncho@gmail.com>
> Date: Sat, 23 Mar 2019 15:31:39 +0200
> Cc: S=C3=A9bastien Chapuis <sebastien@chapu.is>,
>=C2=A0 =C2=A0 =C2=A0 =C2=A031138@debbugs.gnu.org
>
> Take a look at the following piece of code:
>
> https://gist.github.com/yyoncho= /9e9c4e14734fdd9a22d6600a88a27ae1
> (with the latest emacs compiled from master)

OK.

> Unfortunately, I wasn't unable to reproduce the behaviour with &qu= ot;emacs -q" and even it does not reproduce
> right after I load my emacs configuration but after doing some navigat= ion/coding.

Sorry, I don't think I understand what behavior you were unable to
reproduce.=C2=A0 Please elaborate.

> I believe that native parsing is
> calling some function list defined in the elisp space but I am unable = to track down this.

Maybe so, but I don't think I see a Lisp function called from json.c co= de.

> Please, let me know what I can do to help to diagnose this issue.

Are we still talking about too-slow performance of json-parse-string?
If so, and if you think some Lisp code is responsible for that, then
running your benchmark test under profiler.el would be the first thing
I'd suggest.
--0000000000001bac640584c3d9cf--