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: Tue, 12 Mar 2024 11:58:42 +0100 Message-ID: <87jzm7itw8.fsf@gmail.com> References: <87a5n96mb5.fsf@gmail.com> <20240309203725.x456m7c6soxtgj6q@nullprogram.com> <86jzmawqbm.fsf@gnu.org> <87ttldydf2.fsf@posteo.net> <867ci8vqvl.fsf@gnu.org> <5396AC95-1D8F-4A89-B4A8-647B717A1E3C@gmail.com> <87r0ggdcki.fsf@gmail.com> <437D901F-CEC6-45E0-8ABE-B036A7B0AAF5@gmail.com> 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="9863"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?Q?Herman=2C_G=C3=A9za?= , Eli Zaretskii , Philip Kaludercic , wellons@nullprogram.com, emacs-devel@gnu.org To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 12 13:23:01 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 1rk19o-0002OJ-VW for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Mar 2024 13:23:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk06E-0004Xg-52; Tue, 12 Mar 2024 07:15:16 -0400 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 1rk05u-0004Ug-Io for emacs-devel@gnu.org; Tue, 12 Mar 2024 07:14:55 -0400 Original-Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk05r-0006ra-R3; Tue, 12 Mar 2024 07:14:54 -0400 Original-Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-33e9df3416bso993197f8f.3; Tue, 12 Mar 2024 04:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710242090; x=1710846890; 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=mXpRGf/7BPIqLP8R0M40XLszZ1sHjkM51s/7kuWj7Fk=; b=MNkZyS6jG7e0oeO9jCnaVcT49dXcGDbUINN1Ee5w/bPlB3z5dX0eJURpFcuHDJoCXk hHWTraxXQRJbQow81AFBztgh4xrdArnhEYlaTji4RntvR7fxm6qEnyjF9KC6k0BTWnHg T5Y1eCbybvaY8qpqwAbuAkTBYufVUJLqikCKSH31Cv+vO212YdVyqStv6ttoYy5sSHX1 Ar+85/v3UqpGZdjC9TmmOxRTSQabUWI796mi41rBLCjPmpJcogIOj7VBg1a+K5BhU7K/ J335/FB9I8+FEjTr+nKgY9Zc0DhYjhVUV8jKKIXGjCLXBFRv5WJ33+dpdL8UAmORraun z14A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710242090; x=1710846890; 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=mXpRGf/7BPIqLP8R0M40XLszZ1sHjkM51s/7kuWj7Fk=; b=a5Lbo4jfMPZuRCEvgQEUZy7emueC3iL54h3gy9ESnoKZUK8qmU8tqAkFDfaxBT8V3I smSNOC79ksvF5PqFq8+hR93qCkOBkGCyQazS6iXCLvjYrJ/0/Nt4a1zLbBgal6K+Yl1G wIAOWZW9IFVEu0nAodZ+v+wu3ilplSfdB3leqoHU8j9xWvFWs02V0zoSu7ld4+2UH9j8 Wvm62QBtvZu+mL3KpLeLw/gSpL5EohFhrtDgVBXYl1lGfSiKcq41epnRHRWVfWG6GtOF Gfek9PrxArNyDjvC4VYQNO97GzEj7RiybSpBG94NGQTN+RUjvJodaXCJwSWZRuOTxk4o JgHA== X-Forwarded-Encrypted: i=1; AJvYcCWtVbpA6gPWYuJC48e7AvVME97/4r2JiHnpklhc4Or6ECx92bu7xfWYPBVD6aVG/tImxPctm3ShglcEp6pJxhUzyXpb8+RK8Tt7itKTkjttdoo= X-Gm-Message-State: AOJu0YxcDnD1WSLQUSDUi95UYyoqsXgcvXgJh9/W2TSdpmXEKufDv1O8 Nkz20W51jeouVMwjIkJIJ+VnWr4qvYoQEP7004WDhVvNxebTQ6M7 X-Google-Smtp-Source: AGHT+IH0F0qBhuQ/m1KaGbYjhQpDpklLuw/iU9TcJmn50BVBH9kznNKQI0lcDB83bIQXKympq2YEkg== X-Received: by 2002:a5d:408a:0:b0:33e:7404:be91 with SMTP id o10-20020a5d408a000000b0033e7404be91mr6365064wrp.43.1710242089408; Tue, 12 Mar 2024 04:14:49 -0700 (PDT) Original-Received: from localhost (netacc-gpn-204-24-169.pool.yettel.hu. [5.204.24.169]) by smtp.gmail.com with ESMTPSA id he5-20020a05600c540500b00413544f0016sm1262721wmb.19.2024.03.12.04.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 04:14:49 -0700 (PDT) In-reply-to: <437D901F-CEC6-45E0-8ABE-B036A7B0AAF5@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=geza.herman@gmail.com; helo=mail-wr1-x433.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:317015 Archived-At: Mattias Engdeg=C3=A5rd writes: >> I added that easily, tough admittedly it's a little bit=20 >> awkward to >> maintain these variables. If emacs has a way to tell from the >> byte-pointer the line/col position (both for strings and=20 >> buffers), I >> am happy to use that instead. > > Since error handling isn't performance-critical it doesn't=20 > matter if it's a bit slow. (I'd just count newlines.) Basically this is what the current code does, it's just not=20 postponed until an actual error, but registered during parsing.=20 I'm tempted to keep it as is, as line/col information can be=20 useful in other circumstances as well. Like, for example, if we=20 wanted to tag the created objects with their source location. > You can't test that code is GC-safe, you have to show that it's=20 > correct by design. Sure, but there has to be an explanation why the current way=20 doesn't have any problems. Having a glance at garbage collection=20 in emacs, it seems that it only runs during elisp code execution=20 (is this true?). As the parser doesn't call back to any elisp=20 code which runs the VM, it should be safe. If GC could happen any=20 time, then I suppose the whole C Emacs code should be checked for=20 that, because one can never be sure that if something is allocated=20 at the C side, then at the very next moment it will be immediately=20 freed by the GC. Conceptually, I see no difference between calling=20 a single Fcons vs. the what the whole parser does. If calling=20 Fcons and then using its result is safe, then the parser should=20 also be safe. Or is there some magic about the GC which makes this=20 argument false?