From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#31138: Native json slower than json.el Date: Mon, 22 Apr 2019 01:12:49 +0300 Message-ID: References: <87sh806xwa.fsf@chapu.is> <83d0mgnn31.fsf@gnu.org> <835zs7och6.fsf@gnu.org> <83tvfqnbxc.fsf@gnu.org> <83lg12n75s.fsf@gnu.org> <83h8bqn2ik.fsf@gnu.org> <83zhphliil.fsf@gnu.org> <181b93a3-3861-0481-1b95-8344410d1049@yandex.ru> <83r2a2hdxn.fsf@gnu.org> <21f68973-a684-2a65-82eb-c8f3df90127f@yandex.ru> <83d0lmgez2.fsf@gnu.org> <7d503be9-4d85-3d0b-6829-631ad376ba3d@yandex.ru> <831s22gcci.fsf@gnu.org> <83y349gasn.fsf@gnu.org> <83d0lfag4x.fsf@gnu.org> <5cf45a21-65c3-67ee-f123-be83a6ee7c99@yandex.ru> <83a7gjaen6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="167097"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Cc: sebastien@chapu.is, yyoncho@gmail.com, 31138@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 22 00:26:53 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 1hIKvB-000hIm-Fo for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 00:26:49 +0200 Original-Received: from localhost ([127.0.0.1]:57775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIKvA-00065A-Fu for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Apr 2019 18:26:48 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIKuz-00060g-GK for bug-gnu-emacs@gnu.org; Sun, 21 Apr 2019 18:26:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIKio-0001q4-1z for bug-gnu-emacs@gnu.org; Sun, 21 Apr 2019 18:14:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35707) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIKin-0001or-Tj for bug-gnu-emacs@gnu.org; Sun, 21 Apr 2019 18:14:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIKin-0000b7-LO for bug-gnu-emacs@gnu.org; Sun, 21 Apr 2019 18:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Apr 2019 22:14:01 +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.15558847822217 (code B ref 31138); Sun, 21 Apr 2019 22:14:01 +0000 Original-Received: (at 31138) by debbugs.gnu.org; 21 Apr 2019 22:13:02 +0000 Original-Received: from localhost ([127.0.0.1]:49251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIKhq-0000Zh-5u for submit@debbugs.gnu.org; Sun, 21 Apr 2019 18:13:02 -0400 Original-Received: from mail-lj1-f178.google.com ([209.85.208.178]:46926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIKho-0000ZC-02 for 31138@debbugs.gnu.org; Sun, 21 Apr 2019 18:13:00 -0400 Original-Received: by mail-lj1-f178.google.com with SMTP id h21so8793861ljk.13 for <31138@debbugs.gnu.org>; Sun, 21 Apr 2019 15:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ra8xpBFlLMVq3lHlHCf2D4V2Xmuevx9/7FX04iTTwgA=; b=VG3hb75StHfU6ZazMi6ZVg1KINW/omZmk+l3uRwcFtk6+PPRiGtKJNgie/R9qPh/1G eqkw/itjRpLxe2m+Yv/vpwgmhhAvwfF5piJ27hUvt7o21ZZ6SlzFHns57ZqzuxrglLIC NMSRx199L7cmO3vKNZFbXFVyF7GMDY9V8sHCsIkfual5Gi9xh+Edtyjgh87Go3n9cSj9 UpR7Vpam3LixkqHdGkW9vNjKnEszepeKp0lnTkb18m72jBrK8kNnzs0axbzPTgzvQVvi PWwaibPONQnFvjmPWMp1G7pWfBWg00z0ssfCJfzZ8RUzrLtgdaHMgubfxSJ/JuNGUID4 iJyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ra8xpBFlLMVq3lHlHCf2D4V2Xmuevx9/7FX04iTTwgA=; b=BObScEHldLy1PHZXWkrHkjzXWOU5jAIqwiS3vHQ7ptufku5SIk6c6ZUJz4UFsKanYt 3lbeL+P8c6RM5xAokS8Wexp3bM39pw9H4xq9/mj/blWPztxdJYtnV6k7vCbMUP85lWW2 B+OivKx7Ctz4HDur4kj1HJcrp9xcxpwYhSi81GNzahZx5XPdZjC+VfZijrOuq8nmRRI7 eBaHwmbWGI4G32XxuV0nDtvktjOAnLS0hdAZW9ZnzGat6533IoOpI1yPgt44Qmu5Uiy3 WLUsekxyz0m2t7DeB8TWcB8cyLlTwRduy97MYc7eIk60j53dUYZsDqK5KQvJ2cuTe03V J1Ig== X-Gm-Message-State: APjAAAWVnuS8P2ammztjpWFzu7DOwVODm9RaOuGhVB76U1Ggz1jlS2sD qUAupQZ4KsUtTtpe53LhYIuFk4yq X-Google-Smtp-Source: APXvYqxY7AODS2gpyyR67ou3cRiU1BxNgs8yUQ0R+hFuJlin8w14vPnuyFZ387DzC2e5kdr1NEwVUw== X-Received: by 2002:a2e:81da:: with SMTP id s26mr8337103ljg.86.1555884773615; Sun, 21 Apr 2019 15:12:53 -0700 (PDT) Original-Received: from [192.168.1.3] ([185.105.174.23]) by smtp.googlemail.com with ESMTPSA id n9sm2654757lfl.35.2019.04.21.15.12.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Apr 2019 15:12:52 -0700 (PDT) In-Reply-To: <83a7gjaen6.fsf@gnu.org> Content-Language: en-US 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:157972 Archived-At: 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.