From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: I created a faster JSON parser Date: Fri, 08 Mar 2024 14:59:37 +0200 Message-ID: <86y1aszxom.fsf@gnu.org> References: <87a5n96mb5.fsf@gmail.com> <861q8l0w2c.fsf@gnu.org> <878r2s99j0.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26879"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?Q?G=C3=A9za_Herman?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 08 14:00:26 2024 Return-path: Envelope-to: ged-emacs-devel@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 1riZpq-0006nR-L9 for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Mar 2024 14:00:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riZpB-0002r8-Qq; Fri, 08 Mar 2024 07:59:45 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riZpA-0002qm-3e for emacs-devel@gnu.org; Fri, 08 Mar 2024 07:59:44 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riZp8-0003Jo-3R; Fri, 08 Mar 2024 07:59:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=6Y89QZDlC3A2ce2dpY09PydXEOON4AgXHXSWJdwRdpg=; b=K3hBmH4f8+JA560YoJYI C6/nTb/Lb5lNXeetPybJjoRLNOD0rxCEjLFV9SgA7lDMWmHCLRAxfU35LGDPYopx4WQBmDPcYmDjq FBN+7Bqzv9KgKFIMM42rIx+edLIiSXarAZVQTRllx3PfdC6JSp4dYeCSYWBR+J/Wif9YLtrhlOCjG CiPduPLTZhcdFT9qSx0Zd+mXwASsp9ttn5RXLvWOnv26dOMrSD7pq9ydMgYgOZQxY7n9DGBsUuQD9 kME63R/DFrulafM+73y1ntSiq3SAD1CRbWaoHnk2MjARu4oJq/3oBExny/q52htiZxslNyT/70gN9 5MInISeMHk2RGg==; In-Reply-To: <878r2s99j0.fsf@gmail.com> (message from Herman, =?utf-8?Q?G?= =?utf-8?Q?=C3=A9za?= on Fri, 08 Mar 2024 13:38:48 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:316904 Archived-At: > From: Herman, Géza > Cc: Géza Herman , > emacs-devel@gnu.org > Date: Fri, 08 Mar 2024 13:38:48 +0100 > > > Eli Zaretskii writes: > > >> From: Herman, Géza > >> Date: Fri, 08 Mar 2024 11:27:16 +0100 > >> > >> This parser runs 8-9x faster than the jansson based parser on > >> my > >> machine (tested on clangd language server messages). > > > > How does it do that? Can you summarize the main ideas of your > > implementation, which make it so much faster? > > My parser creates Lisp objects during parsing, there is no > intermediate step as Emacs has with jansson. With jansson, there > are a lot of allocations, which my parser doesn't have (my parser > has only two buffers, which exponentially grow. There are no other > allocations). But even ignoring performance loss because of > mallocs (on my dataset, 40% of CPU time goes into malloc/free), I > think parsing should be faster, so maybe jansson is not a fast > parser in the first place. Thanks. So, if you are willing to contribute this code to Emacs, what is left is: . clean up the code (e.g., currently it still calls the function that on MS-Windows loads the jansson DLL, which is now unneeded) and adjust it to our style and conventions; . thoroughly test the code on the available test suites (or maybe you already did); . for you to assign the copyright to the FSF, without which we cannot accept such a substantial contribution As an additional idea: perhaps initially we'd want to have a configure-time option to either use your parser or jansson, to make the migration and comparison easier. What do others think about this?