From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: String encoding in json.c Date: Tue, 26 Dec 2017 21:50:33 +0000 Message-ID: References: <83tvwhjyi5.fsf@gnu.org> <83po72ixs6.fsf@gnu.org> <5e8f561a-fac1-1dbb-1686-d04ef4dfa42c@yandex.ru> <83efnihzse.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a1144d8b24e991f05614546f8" X-Trace: blaine.gmane.org 1514324979 22456 195.159.176.226 (26 Dec 2017 21:49:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 26 Dec 2017 21:49:39 +0000 (UTC) Cc: emacs-devel@gnu.org, Dmitry Gutov To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 26 22:49:34 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eTx6M-00056b-5L for ged-emacs-devel@m.gmane.org; Tue, 26 Dec 2017 22:49:34 +0100 Original-Received: from localhost ([::1]:58690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTx8G-0002oW-24 for ged-emacs-devel@m.gmane.org; Tue, 26 Dec 2017 16:51:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTx7X-0002o1-Gr for emacs-devel@gnu.org; Tue, 26 Dec 2017 16:50:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eTx7W-0008Af-N6 for emacs-devel@gnu.org; Tue, 26 Dec 2017 16:50:47 -0500 Original-Received: from mail-qk0-x231.google.com ([2607:f8b0:400d:c09::231]:43767) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eTx7U-00087I-Ov; Tue, 26 Dec 2017 16:50:44 -0500 Original-Received: by mail-qk0-x231.google.com with SMTP id j137so26864293qke.10; Tue, 26 Dec 2017 13:50:44 -0800 (PST) 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=sLL454IqaI4fLdnkNVN1lcMTP9DJxa1HklCFCsAhSZQ=; b=Lro2Mw4QA/jvpm8deyilNIy9RyfiXPdcpCKxYNSJrjMcJlcUCSFsVHqQ8lMFMVy2ES 7K4A3AV04xnQzLDQTaf/FKhuhbH10I8I/F6ovB/DOcoVSe2aiWXFODPl1f4EzxIExuWd 9FnAACFRinGquv3Tjyv50Z9rlM5BQYvI/ODePupOKqWzyxqv1gTBNPKgslf33i3xE7bg WZDbcr49yAyv7pXpQBw33qBBse4eF3WDeORep3+KKU22UmSAqCVtxIAu7o8HCjCen8CY tZs4YpFOIRHb8g9qfZYwy3PMJa3GjHgz3LY4ojTyaixB861PQoBAQ9bOKycC1Iz3gREb 6FdA== 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=sLL454IqaI4fLdnkNVN1lcMTP9DJxa1HklCFCsAhSZQ=; b=pM02rRjmkz+fo/66iPK1HndImEM3oJ2ULXu+doiDzyiLOerGOMbrfcY5SaY19iH8c6 W0Qb1RQ6Nxuq9+JTSA+mqy1hSl6hYrQ7SsQ8dXHxbbuB/rhAL4TxqacbAhhOhLUlfzL+ aFjvQ/qF7DSKADHeAE8S+tXQkcVSgDdJCi1WV7o5L3fdDfClV8rmf6X5z9szESSnX0UD YMXoaAfhzCdZOg8k+YIVfp1blNQfmdmBe2BXGCEsUxUGBcI0HfF/CzGpB2ju4rNPOUmT oYKFmjwofkuLmWXNJonb41tzi7VqgWOSN56HxLcDqlbbC0Un8n8TpsHW+x10FH/D7X+U YoTA== X-Gm-Message-State: AKGB3mJysHKL+Wb6nBRq7fOOMmXqvrheVhad9QCTBvEkUKs3piFhdx0n lp0vYIjvbSB/dWm64xxJFZ/Kpc+bDlUuWdVBf8x9Tg== X-Google-Smtp-Source: ACJfBosEHsoguMYFLGrsnvv8q0uBgLiQwfhDo7vsBzLlNvsL2XKb6iKCepsuxMXN6JkoAts53+DcFm2cbi2LDSpMICo= X-Received: by 10.55.33.17 with SMTP id h17mr31693219qkh.143.1514325043745; Tue, 26 Dec 2017 13:50:43 -0800 (PST) In-Reply-To: <83efnihzse.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221430 Archived-At: --001a1144d8b24e991f05614546f8 Content-Type: text/plain; charset="UTF-8" Eli Zaretskii schrieb am Di., 26. Dez. 2017 um 05:35 Uhr: > > > I'm not sure which encoding speeds json.c allows us now. > > Well, Philipp measured it, so maybe he could share the benchmarks and > the results. > json.el itself got some speedups from the time of that bug report, as Dmitry mentioned in the bug. My benchmark is a relatively dumb microbenchmark that calls the JSON functions 20 times on the data files in nativejson-benchmark. Then I ran that code through the `bench' program, which does some basic statistical analysis. Serialization is in all cases more than 5 times faster, with a high significance. > > > But the JSON structure I was talking about is not written to a file. > > It's sent over the network (usually to a local TCP socket). > > In that case, encoding it is not a wasted effort, since it would have > been otherwise encoded when we send it. > If that turns out to be a problem, we might consider returning a unibyte string to avoid further encoding. --001a1144d8b24e991f05614546f8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Eli Za= retskii <eliz@gnu.org> schrieb am= Di., 26. Dez. 2017 um 05:35=C2=A0Uhr:

> I'm not sure which encoding speeds json.c allows us now.

Well, Philipp measured it, so maybe he could share the benchmarks and
the results.

json.el itself got some sp= eedups from the time of that bug report, as Dmitry mentioned in the bug.
My benchmark is a relatively dumb microbenchmark that calls the JSO= N functions 20 times on the data files in nativejson-benchmark. Then I ran = that code through the `bench' program, which does some basic statistica= l analysis. Serialization is in all cases more than 5 times faster, with a = high significance.
=C2=A0

> But the JSON structure I was talking about is not written to a file. > It's sent over the network (usually to a local TCP socket).

In that case, encoding it is not a wasted effort, since it would have
been otherwise encoded when we send it.

If that turns out to be a problem, we might consider returning a unibyte s= tring to avoid further encoding.=C2=A0
--001a1144d8b24e991f05614546f8--