From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Sebastien Chapuis Newsgroups: gmane.emacs.bugs Subject: bug#31138: Native json slower than json.el Date: Thu, 12 Apr 2018 21:13:41 +0200 Message-ID: <87sh806xwa.fsf@chapu.is> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1523560393 17598 195.159.176.226 (12 Apr 2018 19:13:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 12 Apr 2018 19:13:13 +0000 (UTC) User-Agent: mu4e 0.9.19; emacs 27.0.50 To: 31138@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 12 21:13:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1f6hee-0004Tx-4A for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Apr 2018 21:13:08 +0200 Original-Received: from localhost ([::1]:36079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6hgk-0008Bu-QE for geb-bug-gnu-emacs@m.gmane.org; Thu, 12 Apr 2018 15:15:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6hga-0008B0-ID for bug-gnu-emacs@gnu.org; Thu, 12 Apr 2018 15:15:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6hgW-0007AB-Hz for bug-gnu-emacs@gnu.org; Thu, 12 Apr 2018 15:15:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40585) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6hgW-00079e-CM for bug-gnu-emacs@gnu.org; Thu, 12 Apr 2018 15:15:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f6hgW-0003uL-2S for bug-gnu-emacs@gnu.org; Thu, 12 Apr 2018 15:15:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sebastien Chapuis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Apr 2018 19:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31138 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.152356044114806 (code B ref -1); Thu, 12 Apr 2018 19:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Apr 2018 19:14:01 +0000 Original-Received: from localhost ([127.0.0.1]:48476 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f6hfV-0003qd-Id for submit@debbugs.gnu.org; Thu, 12 Apr 2018 15:14:01 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38182) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f6hfT-0003q8-LL for submit@debbugs.gnu.org; Thu, 12 Apr 2018 15:13:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6hfN-0005Vs-FO for submit@debbugs.gnu.org; Thu, 12 Apr 2018 15:13:54 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:40514) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f6hfN-0005Vh-BF for submit@debbugs.gnu.org; Thu, 12 Apr 2018 15:13:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6hfI-000794-P1 for bug-gnu-emacs@gnu.org; Thu, 12 Apr 2018 15:13:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6hfE-0005Sz-Pn for bug-gnu-emacs@gnu.org; Thu, 12 Apr 2018 15:13:48 -0400 Original-Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:34173) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6hfE-0005Sj-HG for bug-gnu-emacs@gnu.org; Thu, 12 Apr 2018 15:13:44 -0400 Original-Received: by mail-wr0-x22e.google.com with SMTP id d19so6130305wre.1 for ; Thu, 12 Apr 2018 12:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chapu-is.20150623.gappssmtp.com; s=20150623; h=user-agent:from:to:subject:date:message-id:mime-version; bh=rGrDCdsxroG5C2JgtbFKg5nYokBd1nJzpeg43EFHRF8=; b=cSq0jt0RkLFDegTk+O8q9w2FZebiILyNd82Gj2vDG5YO4uL7B8E4mAq/SJs2hjf4hi dPMRxpVEy+HMUsAFKfhtoouQoyFUQLMGWaxZo4LHEA4Ta+RTCZzzS70mq6aVMKfp+7EH aUpVbie5t0rFBdW8q+2a4vHs1lACH/BErvzuSLk9W/9QqlvbOGz/Rvw+7qqP8LCwAmmx 2/Lsm3ISCFb7tt2x5olM+0ve/KnpTOk1WLgyw0o/uTX4tmJg3JhlrovT5hTW5HVOgGHm 80FsdCwIpa4LbPyY7c5DOifD2Gq5Y6fhGkxaroZQZ+UBNJf9jw7yu7xs12P7kneAL5j+ 5rJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=rGrDCdsxroG5C2JgtbFKg5nYokBd1nJzpeg43EFHRF8=; b=qreP/8qaSLCa9H8DSbreBv9TMX/S61S32jkfbrBujYao5vmVmnf/PCI7+LSI9Udl9A 6NSRH0XSdc4LAyRIAExZtLEiOeKVm3Tf5Wac/7Pj6Qtq+6ZVO29bu0luJ0XJAtb/+Wbe 8sddeDc8MpCvw/uBD/Nuit4Cxn1asUltgHeSYqMcPzTVF9lg2oocZAKtwz4HNYFelLE3 AX+1UOsUO+dkv3F+HXo8ux+dv2rHEwX+Q6BH1aRjF3GeErf6cyB82ENsYRXS+gGJY08t 517s6RcfoTD1y9Fhn74RmKyMRx6lwG0KXcjLBTAmF3rF88u3ZpNoMO2D2KDiYY/M0l5Z w//A== X-Gm-Message-State: ALQs6tAwQSlyHfOhc5QZIsrkM6rZxEv0hX4Y3R32SqwsTuBt8KYWTU3i 3dRXT0ILj2a4UdYdOvjZ81+OLSlKMr8= X-Google-Smtp-Source: AIpwx4/JNBn0RL/FtNgPFpNVpFCEhR/AWqj2hQiAWSekaY0NOti0W/NeuhuiStxpx7WpyQDvUYF/Xw== X-Received: by 10.223.190.142 with SMTP id i14mr1565717wrh.168.1523560422981; Thu, 12 Apr 2018 12:13:42 -0700 (PDT) Original-Received: from XPS13 (188.226.99.84.rev.sfr.net. [84.99.226.188]) by smtp.gmail.com with ESMTPSA id a70sm96552wma.27.2018.04.12.12.13.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 12:13:42 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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: 208.118.235.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:145192 Archived-At: --=-=-= Content-Type: text/plain Hi, I have tested the new function json-parse-string to use it in lsp-mode and was suprised when I found out that this function is slower than json-read-from-string from json.el: Test with a string of 4042446 characters: ``` json-parse-string: 9,166010 seconds json-read-from-string: 6.028625 seconds ``` I took a look at the code, and if I remove the call to code_convert_string in json_make_string (see the attached diff), it's way faster: Test with a string of 4042411 characters ``` json-parse-string (without code_convert_string): 0.505582 seconds ``` Is this conversion really necessary ? Should I set some variable to avoid this ? By the way, what is the state of this patch: https://lists.gnu.org/archive/html/emacs-devel/2017-12/msg00916.html Could it be merge ? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=json.patch Content-Description: patch diff --git a/src/json.c b/src/json.c index b046d34f66..1fc976214d 100644 --- a/src/json.c +++ b/src/json.c @@ -219,8 +219,7 @@ 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); + return make_specified_string (data, -1, size, false); } /* Create a multibyte Lisp string from the null-terminated UTF-8 --=-=-= Content-Type: text/plain -- Sebastien Chapuis --=-=-=--