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 <eliz@gnu.org> wrote:
> From: yyoncho <yyoncho@gmail.com>
> Date: Sat, 23 Mar 2019 15:31:39 +0200
> Cc: Sébastien Chapuis <sebastien@chapu.is>,
>       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 to 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.