From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Herman=2C_G=C3=A9za?= Newsgroups: gmane.emacs.devel Subject: Re: I created a faster JSON parser Date: Fri, 08 Mar 2024 13:38:48 +0100 Message-ID: <878r2s99j0.fsf@gmail.com> References: <87a5n96mb5.fsf@gmail.com> <861q8l0w2c.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1084"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?Q?G=C3=A9za?= Herman , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 08 13:47:28 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 1riZdF-000AbJ-JF for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Mar 2024 13:47:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riZcL-00076z-9J; Fri, 08 Mar 2024 07:46:29 -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 1riZcE-00075b-G5 for emacs-devel@gnu.org; Fri, 08 Mar 2024 07:46:25 -0500 Original-Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riZbt-0007p3-9c; Fri, 08 Mar 2024 07:46:06 -0500 Original-Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2d2505352e6so27593811fa.3; Fri, 08 Mar 2024 04:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709901958; x=1710506758; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:references:from:to:cc:subject:date:message-id :reply-to; bh=DYCy9g2gxDJvEUab3Mt2RVUM4iSQDSQT1sW1Yj5SbFI=; b=DI0VxPflok1IbxDpIlBo0JvAro87CNVMqn7MKi5OLTiueH8Qj27/B80xmBWTysIlzC 16Cs/UiKxeOo6nEW7coLEOxRexscQSBXSOsg4QvD59b8npUzND51ehmiw1fyvkIw21+Z dFhHXDu6q4ySv08AcydDux3WIZnUViHw9GPg28PobqxFWbnq/w1NdPHUNEBmLHQL1Lom 2WwjYWhAZfau+BK9AyB+fxeYK1F0ukf7hZVCKVml9SHTVVs+cNJBbiVNCdf9SdKxHCEx qWkKlfQF92APNQPJLz5JaznY92n4UWIwWzZVuDv/ynevaijMGBjvObWdenSFxPG1dFq7 Lg9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709901958; x=1710506758; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:references:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=DYCy9g2gxDJvEUab3Mt2RVUM4iSQDSQT1sW1Yj5SbFI=; b=uP1o/fQrlmPUs34XNDGgeXhK8n/02rEOW2MunyTLr7KifE9t6wFT1yqCX7oZ6T1Ath BRBER5Kz7XR09JyqGk1vFo0tcFUnMiU3J5qhAVfAfaeI4SAp7en8TWllJOdg0ktw59Tp 7ELjQmzLFQOW8JNOPKYextHWamQR+j6aQiWR8E6x4gZM2Ik7DX04EFe4Kc6xdm/eml1h uVAl4i+y/boZva/M+kuupncMrGWqlbPBbptz9YJ47q1x3RM+l2U91PsufTQwABYIEOom gHPlpz59+2AeWQXPI9QIekYzRxI5q8xNsqF+zP3y9O6L7i3+m803/GmqP4MQPA98MYC2 XUZA== X-Forwarded-Encrypted: i=1; AJvYcCUxUbaDWIQmioXdHR0x4yxq8jdF3i2C2nxZYfYzoSP2q2EWO/W819wQ1cD660SqfFS300X6nL/bXTNdKivIimYKENVV X-Gm-Message-State: AOJu0YySd0pnZyX8ATSQMrNb78iCFI1PMyeUJlFnMhtZFsBzWWUjb9al 280Z54vfWzGZZNQFh+f+jHn4wlAD0TtAxSp7JUN/Y6c4/AyBJ+Fi2/RcU1RF X-Google-Smtp-Source: AGHT+IEYfjWwwV8nO8EclMRs5dl4DCRLqcLOgG4jzsXxOFcVyBqY2Bb7yvfxPqzxtEyiGSFcIJKxGQ== X-Received: by 2002:a2e:9c05:0:b0:2d2:4783:872a with SMTP id s5-20020a2e9c05000000b002d24783872amr3334038lji.29.1709901957423; Fri, 08 Mar 2024 04:45:57 -0800 (PST) Original-Received: from localhost (netacc-gpn-4-80-29.pool.yettel.hu. [84.224.80.29]) by smtp.gmail.com with ESMTPSA id fi12-20020a056402550c00b005661badcccesm8970936edb.87.2024.03.08.04.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 04:45:57 -0800 (PST) In-reply-to: <861q8l0w2c.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=geza.herman@gmail.com; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:316902 Archived-At: Eli Zaretskii writes: >> From: Herman, G=C3=A9za >> Date: Fri, 08 Mar 2024 11:27:16 +0100 >> >> This parser runs 8-9x faster than the jansson based parser on=20 >> 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=20 intermediate step as Emacs has with jansson. With jansson, there=20 are a lot of allocations, which my parser doesn't have (my parser=20 has only two buffers, which exponentially grow. There are no other=20 allocations). But even ignoring performance loss because of=20 mallocs (on my dataset, 40% of CPU time goes into malloc/free), I=20 think parsing should be faster, so maybe jansson is not a fast=20 parser in the first place.