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: Tue, 23 Apr 2019 00:00:29 +0300 Message-ID: <46f710a2-1e2d-335e-99cf-340fd84b4ef8@yandex.ru> References: <87sh806xwa.fsf@chapu.is> <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> <10ca4e2f-b116-16bc-c81e-24036752c867@yandex.ru> <83lg026xxb.fsf@gnu.org> <0d42dab4-6c5c-be3a-d402-f17b39e7fc3c@yandex.ru> <83k1fm6vly.fsf@gnu.org> <19b19dec-a5a0-e08d-6026-0b9621d38143@yandex.ru> <8336ma6oia.fsf@gnu.org> <83tveq56jr.fsf@gnu.org> <83pnpe55hp.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="139723"; 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: p.stephani2@gmail.com, 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 23:17:56 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 1hIgK4-000aG8-K5 for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 23:17:56 +0200 Original-Received: from localhost ([127.0.0.1]:44373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIgK3-0006iy-Jr for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 17:17:55 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIgEH-0002UV-IH for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 17:11:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIg3i-0005j5-7L for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 17:01:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38184) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIg3i-0005j1-4C for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 17:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIg3i-0006IA-2g for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 17:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Apr 2019 21:01:02 +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.155596684524155 (code B ref 31138); Mon, 22 Apr 2019 21:01:02 +0000 Original-Received: (at 31138) by debbugs.gnu.org; 22 Apr 2019 21:00:45 +0000 Original-Received: from localhost ([127.0.0.1]:51728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIg3Q-0006HX-SK for submit@debbugs.gnu.org; Mon, 22 Apr 2019 17:00:45 -0400 Original-Received: from mail-lf1-f68.google.com ([209.85.167.68]:42451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIg3M-0006HH-KM for 31138@debbugs.gnu.org; Mon, 22 Apr 2019 17:00:41 -0400 Original-Received: by mail-lf1-f68.google.com with SMTP id w23so9966936lfc.9 for <31138@debbugs.gnu.org>; Mon, 22 Apr 2019 14:00:40 -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=TXqN5Ajabxn8clUKzJi/55XQg/1/m/xfDEhdoXzAQZI=; b=PK5Ob1oazoyEc5UIPripxTSAE1p/okP9MVURuPeP0zRHPmk3ZG+aHmXUl7u+7wOcQ7 +7GyXIThVXI88VxXf/tmr/8ZV4vzzU1+0ettLbWOunAjIHjINdgrMQuze+ZR3q+hDREd RtFID0wQdaORA8f9xJ6MLQITnSYyS98XW3Hh5D+wkByzU95p0THomg6vlUd6Z85AaiB7 AGHxZaUjrii+iLFoz9Z9xy1K90uQevFXMB8oUMBRjBAySlgdOfq6QY1yAvNbaaGzWBUW MFZv3eEsPPn8EuGYOQ/QFfjVwC0MmR47msjjM2F1c6ncR9b3usrIveoFXUvUINnpgsuU 1tlw== 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=TXqN5Ajabxn8clUKzJi/55XQg/1/m/xfDEhdoXzAQZI=; b=B1Wu3ZoVWLtxrTFLyCbHj8NlyU1bverFk9EQHKu2FpmoMYqums+EGbRhTg9JNbmI12 deELVPDEvXQZcACuTS6YuxV/C9sLKHS9vbuI2GdV/6PwXL9vmjftxwz6LYBV9O2p7WIl VHb9Ohoapbiz29EV4IbCKL1UTdtHJyTtcZsIudxkoArlEYaglnPzj9UJxNKBG3MlGG2o Nz0iN76KGLN0dFk5ldr7WBiyFxZRQ2ZmsjNhQYbFYwQ/zpkZYH51qCKubc5tnTPhPVat l5csqsSPwMrxiGgaIgk7cICwowzkODzq+Ya98woLkdpCg3olByBzSxCsVgTKoXFViTrm OfGw== X-Gm-Message-State: APjAAAUN+6lefmdokF3lKtUu9JlPsL6CReIT17QkVAt0tc7iadlG+L9M 7SNbtH94ld9arOgOTb3H6b8vn6qW X-Google-Smtp-Source: APXvYqyghOF6OV+uO3Bft8kL3cRFrLLoVo0BfGD39Tyuy93JXiJvta+hDxHh8DUl4TkbDbnPWaQ0Rw== X-Received: by 2002:a19:7d42:: with SMTP id y63mr3562910lfc.92.1555966834072; Mon, 22 Apr 2019 14:00:34 -0700 (PDT) Original-Received: from [192.168.1.3] ([185.105.174.23]) by smtp.googlemail.com with ESMTPSA id s24sm2908771ljs.30.2019.04.22.14.00.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Apr 2019 14:00:32 -0700 (PDT) In-Reply-To: <83pnpe55hp.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:158083 Archived-At: On 22.04.2019 20:12, Eli Zaretskii wrote: > Like this: > > diff --git a/src/json.c b/src/json.c > index 16500bc..48aeccf 100644 > --- a/src/json.c > +++ b/src/json.c > @@ -225,8 +225,12 @@ json_has_suffix (const char *string, const char *suffix) > static Lisp_Object > json_make_string (const char *data, ptrdiff_t size) > { > - return code_convert_string (make_specified_string (data, -1, size, false), > - Qutf_8_unix, Qt, false, true, true); > + struct coding_system coding; > + setup_coding_system (Qutf_8_unix, &coding); > + coding.mode |= CODING_MODE_LAST_BLOCK; > + coding.source = data; > + decode_coding_object (&coding, Qnil, 0, 0, size, size, Qt); > + return coding.dst_object; > } > > /* Create a multibyte Lisp string from the NUL-terminated UTF-8 > > > How does this fare in your benchmarks? It's not nothing, but it doesn't remotely compare to avoiding the decoder entirely. Here's a table with different patches and corresponding timings. Your last patch is at the end. I have to admit that somehow my previous measurement of the "none" performance was off, maybe due to cold disk cache, maybe due to busy CPU or whatever. So it's not 51s but faster. | patch | runtime (s) | |------------------------------+-------------| | none (current master) | 36.8 | | no validation | 21.7 | | ascii_only check | 21.8 | | using coding_system directly | 34.5 | I have also tried your suggested scenario (where the file is read only once), but it made the "none" case faster by 2 seconds. So I decided against repeating all tests with it.