bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#31138: Native json slower than json.el


From: Dmitry Gutov
Subject: bug#31138: Native json slower than json.el
Date: Mon, 22 Apr 2019 01:12:49 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 21.04.2019 12:31, Eli Zaretskii wrote:

Eli, how did you reach that conclusion?

By adding the percentage of all the functions involved in decoding
strings.

Was the total sum of the profile 100%?

One: looking at the profile, libjansson is somewhere down below, and
most of the runtime is taken by Emacs.

I only accounted for time used by Emacs code, i.e. 100% doesn't
include the library.

I still don't understand. I my profiling report, decode_coding_utf_8 is at the top (Emacs function). Followed by malloc and produce_chars. Are you saying they are not involved in decoding strings?

Two: while I might be misreading the profile, simply omitting the
decoding function call (and using the returned strings as-is) halves the
execution time.

You cannot use the returned string as is, you must make a Lisp string
out of it.

Yes. There's a patch that makes a Lisp string without string additional decoding, and it makes the runtime 2x faster. It's been posted in this report. Would you like me to point at it?

In any case, even if decoding takes 50% of the time we spend in Emacs
code, it is still not significant enough to justify the un-safety of
using a string that we didn't decode, because if that string ever
includes raw bytes, Emacs will surely crash.

What was the point of us doing the exercise, and me wasting time on it, if you're set on not changing anything at all?

We've already had the performance numbers from before.

Given the encouragement, I really expected you to choose *some* path toward improvement. Either forgoing conversion (maybe adding an additional test suite, for cases you're worrying about), or doing some kind of faster validation instead of full conversion (where we don't allocate new strings but just check existing ones for validity), or, you know, optimizing everything everywhere.

Considering libjansson manages to do both JSON parsing and string conversion in ~the same time make_specified_string only does string conversion on the returned strings, it most likely follows that make_specified_string could be made faster.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]