From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#46761: 28.0.50; Speed up json.el encoding Date: Sat, 27 Feb 2021 20:51:05 +0200 Message-ID: <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> References: <87a6rtszgk.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8309"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: "Basil L. Contovounesios" , 46761@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 27 19:52:25 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lG4hV-00023a-A4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Feb 2021 19:52:25 +0100 Original-Received: from localhost ([::1]:51326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lG4hU-0002xj-Am for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Feb 2021 13:52:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lG4hC-0002vq-0o for bug-gnu-emacs@gnu.org; Sat, 27 Feb 2021 13:52:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lG4h7-0008EQ-WC for bug-gnu-emacs@gnu.org; Sat, 27 Feb 2021 13:52:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lG4h7-0004Ry-UU for bug-gnu-emacs@gnu.org; Sat, 27 Feb 2021 13:52:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Feb 2021 18:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46761 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46761-submit@debbugs.gnu.org id=B46761.161445187817052 (code B ref 46761); Sat, 27 Feb 2021 18:52:01 +0000 Original-Received: (at 46761) by debbugs.gnu.org; 27 Feb 2021 18:51:18 +0000 Original-Received: from localhost ([127.0.0.1]:45395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG4gP-0004Qx-Tr for submit@debbugs.gnu.org; Sat, 27 Feb 2021 13:51:18 -0500 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:39555) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG4gO-0004Qj-4E for 46761@debbugs.gnu.org; Sat, 27 Feb 2021 13:51:17 -0500 Original-Received: by mail-wm1-f51.google.com with SMTP id u125so10580092wmg.4 for <46761@debbugs.gnu.org>; Sat, 27 Feb 2021 10:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ayvWnH0PWBBSBRB5xsRSSO1EbGcFPpvA6/qIo6ctWpw=; b=sue+LMZxnfqMjbNB5nQ6nbYvUGLcaBkZVCC0BD5q11eqPH5sshlVupk+loyOGadNaA H7Y/TYtKhvtiWHUc+yxwK1p9Ca7nwZlIM5fjLKkcIM1qjDBEyR3VCofwlOLAPMe6Uu+m UvZFptuWjFS/2e2+v1qYCr/k6J5kigbyfZIoj9Xj7L7UuHgP3qVKpyB/iPUZOKcV1+9P 8rQ5Vv7smI4t27n4Iu/AH8WQKCzv7SzW73OuhEWOMbTOJfgVpn8GdJU0k7REYrdYNL/o sFjEx02VXZW2eZi8l+j7FOuXbNVWLHcF0fiPzuovqBllT2c3n2G+aQ8ciEcZ8Txvnb96 KcHw== 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:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ayvWnH0PWBBSBRB5xsRSSO1EbGcFPpvA6/qIo6ctWpw=; b=XVnU51N9t5fY1uEn99mIzQzhaOmPBJfupfRdzRlwC38hoKfzsHxsU90aMFDl/KreGS NHerXhPxTAIvc3WhIwOd9ldiBWv+AeD+ky2G1JIfMheZaDHkXPfWa09YJhTncxaXlOUP 8YggAQDPA3uYjj/Rsu3mUg5TSD9qdZmqrVdZWqJgKDQqQl64+RBr3Cto5ZLtK3+tq8vL L8BHHyBPF/yVGOdfgHZjEuoufx4ghSY5948rgTOGdwr4B9xppnMSO/H1OIYBVw3SCnZc GQ1nk66IT8wG6vhCwU4kGZnpkGNCvCRzQhkalmR33XCZYjHsJ8M7bvs/adPyTjryY6Ux f/ug== X-Gm-Message-State: AOAM532n2f3+4qkRptuAF9Uz3kqG9CnJWN5iAzwtlj/grlXeEnSb7fEU at+2EXLPfLd+pn3UjE/xeBgq8AQhyRI= X-Google-Smtp-Source: ABdhPJzuk+OTWqJT3UeHJj/6IuhjtyCaac5BlCDI9pw9aq8ScsdvF923EeUm2N+MZ6hDCQR6RQyqUA== X-Received: by 2002:a7b:c353:: with SMTP id l19mr8335744wmj.147.1614451870409; Sat, 27 Feb 2021 10:51:10 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id x13sm17990688wrt.75.2021.02.27.10.51.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Feb 2021 10:51:09 -0800 (PST) In-Reply-To: <87a6rtszgk.fsf@tcd.ie> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:200973 Archived-At: On 25.02.2021 03:33, Basil L. Contovounesios wrote: > Severity: wishlist > Tags: patch > > The attached patch speeds up json-encode by inserting into a buffer > rather than concatenating strings. It does so backward compatibly by > creating a new json--print-* namespace that mirrors the existing > json-encode-* namespace, cleaning it up a bit and reducing code > duplication in the process. > > Using my usual benchmark from bug#40693#89: > > canada.json > old (1.412693239 96 0.736882091) > new (1.154423962 32 0.248241551) > > citm_catalog.json > old (0.676292855 68 0.5285956769999993) > new (0.306573098 12 0.0965493740000003) > > twitter.json > old (0.353447016 40 0.28536439900000055) > new (0.142140227 8 0.05943713899999992) > > Note that one of the unit tests depends on the patch to map.el in > bug#46754 in order to pass. Looking good. I'm guessing there is an approximate size where structures smaller than that size will get slower to encode because of this change (creating a temp buffer and switching to it are not entirely free), but I can't think of a use case where this would matter.