From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Speed of Elisp (was: JSON/YAML/TOML/etc. parsing performance) Date: Sun, 17 Sep 2017 17:17:53 -0400 Message-ID: References: <87poaqhc63.fsf@lifelogs.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1505683105 30723 195.159.176.226 (17 Sep 2017 21:18:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 17 Sep 2017 21:18:25 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 17 23:18:21 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 1dtgxI-0007kn-H6 for ged-emacs-devel@m.gmane.org; Sun, 17 Sep 2017 23:18:20 +0200 Original-Received: from localhost ([::1]:33706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtgxP-00036O-8B for ged-emacs-devel@m.gmane.org; Sun, 17 Sep 2017 17:18:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtgxG-00034m-L5 for emacs-devel@gnu.org; Sun, 17 Sep 2017 17:18:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtgx8-0000L4-Et for emacs-devel@gnu.org; Sun, 17 Sep 2017 17:18:14 -0400 Original-Received: from [195.159.176.226] (port=33548 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dtgx8-0000Jn-6v for emacs-devel@gnu.org; Sun, 17 Sep 2017 17:18:10 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dtgwv-0006uK-D6 for emacs-devel@gnu.org; Sun, 17 Sep 2017 23:17:57 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:/r2KgyMz+slGHh07wN65TfEnZVA= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:218431 Archived-At: [ To clarify up front: I'm in favor of using those libraries. The questions below don't mean that I think it's better to speed up Elisp than to use a C implementation of those json primitives: In any case, it makes sense to use existing C libraries for that, both for speed reasons and for maintenance reasons; like we do for XML. The choice between C and Elisp would only make sense if we had to write&maintain the C code. ] > (license: Expat/X11/MIT), resulting in significant speedups using the test > data from https://github.com/miloyip/nativejson-benchmark: a factor of 3.9 > to 6.4 for parsing, Very interesting. The way I read it, it means either that Elisp is not nearly as slow as we tend to assume, or that the overhead introduced when turning json-c's output into an Elisp-usable form dwarfs the json-c parsing itself. > and a factor of 27 to 67 for serializing. I'm curious why there is such a wide discrepancy between the speedup for parsing and that for serializing (sounds like a factor 10 difference). Is it because parsing with json-c is slowed down by the conversion to (especially allocation of) Elisp data structures, or is it because the Elisp implementation of json serialization suffers more from poor performance (in which case, maybe it could point to a performance issue in Elisp which we could try to tackle)? Stefan