From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: JSON/YAML/TOML/etc. parsing performance Date: Sun, 29 Oct 2017 20:48:02 +0000 Message-ID: References: <87poaqhc63.fsf@lifelogs.com> <8360ceh5f1.fsf@gnu.org> <83h8vl5lf9.fsf@gnu.org> <83r2um3fqi.fsf@gnu.org> <43520b71-9e25-926c-d744-78098dad6441@cs.ucla.edu> <83o9pnzddc.fsf@gnu.org> <472176ce-846b-1f24-716b-98eb95ceaa47@cs.ucla.edu> <83d163z6dy.fsf@gnu.org> <73477c99-1600-a53d-d84f-737837d0f91f@cs.ucla.edu> <83poa2ya8j.fsf@gnu.org> <21b0ba97-ed49-43ae-e86f-63fba762353a@cs.ucla.edu> <8c922c27-9de0-7d99-6c26-a94a0387c45e@cs.ucla.edu> <6ae6864b-3bb9-2e7d-c050-2d26894268a5@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114063d2f702a8055cb5a3b6" X-Trace: blaine.gmane.org 1509310151 28688 195.159.176.226 (29 Oct 2017 20:49:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 29 Oct 2017 20:49:11 +0000 (UTC) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 29 21:49:07 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 1e8uVy-0006J3-GX for ged-emacs-devel@m.gmane.org; Sun, 29 Oct 2017 21:49:02 +0100 Original-Received: from localhost ([::1]:37699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8uW2-0006jZ-8Q for ged-emacs-devel@m.gmane.org; Sun, 29 Oct 2017 16:49:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8uVE-0006jS-Ca for emacs-devel@gnu.org; Sun, 29 Oct 2017 16:48:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8uVD-0002ex-Eq for emacs-devel@gnu.org; Sun, 29 Oct 2017 16:48:16 -0400 Original-Received: from mail-qt0-x22d.google.com ([2607:f8b0:400d:c0d::22d]:52553) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e8uVB-0002eL-W5; Sun, 29 Oct 2017 16:48:14 -0400 Original-Received: by mail-qt0-x22d.google.com with SMTP id 31so14095933qtz.9; Sun, 29 Oct 2017 13:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Zik/3y9V3u0bsaKtDNfHU5OhflJmO0nFVdFjheg+K8c=; b=o4+CJnVtt9c6f5UJZXyz8yMwiiGkwCGXibzgatJO4TCpjwHlWfbG9meKOrrE9sDQqo cqIlk7vwCNL6ruXjr3JEztjq04y+Lym2DZhmb0mIU6a6cZXwIPQe/l0Exxef+7HlBMok h4Tujs1n5uL6W6LbRuGfvNjSBLvrgKIjSJ0E5m+BVfS6ltdBmt4PJn5i72uSSVfRuHPt /rEuESxU66owlb9cO7IcfLYLrhcRrHH6/KptMiiJ5/ucx+jwQBySHUnOCAnH4TTAVDuI IqrENyVIKQjDVI0zQhhJZdrV6NRElQGxivczCg5Y0Bdj/HIWyr7q0TTfIDrIAuzoI8Ic TQcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Zik/3y9V3u0bsaKtDNfHU5OhflJmO0nFVdFjheg+K8c=; b=L2NpJmwYmTxzom+EXyJ0ZwqWvWNcwlm8KQNvSG5PngO6Z/6bQ7PlM8xzNr7QqbaH1I K0UX2QBjDkU8Gc5svuefuPcGoRlvcqkg8x7jT7xlV5fAr4rW6bma6DL6wgMfVXwFJd1a 3PWc0ClLf/FcSuaeZt9aYclCtxdXcfyiPYEYTpNPrF7mgbitoBezVRyJ8204SBHcvFio a6PVCbxDbNtGekW3s8MifEam8GM/FyPxWiVy14Hq1TR2kbH1k55os/eBH8a0iMywjbNN Heuhdp6Q/l9TiHbHp5ekka0fk30ryQcw6EDaYYOGSLVwZClb0tEOXuTrnDS5UEY0oIj/ JrfQ== X-Gm-Message-State: AMCzsaW3o1qIPTkG82Bq6hj/QluKsuvE3bo9vuvM7OMqG/8QvouGZwtz h/JrQylhVcwuXPVmHTYxXnxT9KFOOfr0s+agym8= X-Google-Smtp-Source: ABhQp+QgqMDspPPbcpSRUNfK96QY4rvXPBFuSmApyirf033wA6HC4gBR/aoE9IRC9tnBi9eqh1RhJBgBnThf3ArpNVE= X-Received: by 10.200.44.70 with SMTP id e6mr11327936qta.197.1509310093262; Sun, 29 Oct 2017 13:48:13 -0700 (PDT) In-Reply-To: <6ae6864b-3bb9-2e7d-c050-2d26894268a5@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22d 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:219819 Archived-At: --001a114063d2f702a8055cb5a3b6 Content-Type: text/plain; charset="UTF-8" Paul Eggert schrieb am Mo., 9. Okt. 2017 um 07:54 Uhr: > Philipp Stephani wrote: > > I don't understand why minimizing the number of checks and assertions > > should be a worthwhile goal. At the very least, the assertions document > the > > assumptions that we make about the values, and as such they are valuable > > even if they never trigger. > > One can take the process too far. To take a deliberately extreme example, > 'eassert (INT_MIN < 0)' would clutter the code unnecessarily, and would be > discarded by the compiler anyway. Although none of the assertions in > question > were *that* obvious, some did have that flavor (and indeed, were optimized > away > by GCC). The patch that I proposed eliminated those, while retaining the > ones > that conveyed useful and nonobvious information. Admittedly some of the > removals > were judgment calls; however, the point remains that easserts should not > waste > the reader's time unnecessarily. > I agree, but I think anything that's not obvious deserves to be documented (preferably in the form of an assertion). Such documentation avoids the need to search for other places in the codebase and figuring out which invariants are guaranteed from the implementation. INT_MIN < 0 is already guaranteed by the C standard (although even that is somewhat subtle, given the possibility of different widths and representations of integers, padding bits, etc.), --001a114063d2f702a8055cb5a3b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Paul E= ggert <eggert@cs.ucla.edu> = schrieb am Mo., 9. Okt. 2017 um 07:54=C2=A0Uhr:
Philipp Stephani wrote:
> I don't understand why minimizing the number of checks and asserti= ons
> should be a worthwhile goal. At the very least, the assertions documen= t the
> assumptions that we make about the values, and as such they are valuab= le
> even if they never trigger.

One can take the process too far. To take a deliberately extreme example, 'eassert (INT_MIN < 0)' would clutter the code unnecessarily, an= d would be
discarded by the compiler anyway. Although none of the assertions in questi= on
were *that* obvious, some did have that flavor (and indeed, were optimized = away
by GCC). The patch that I proposed eliminated those, while retaining the on= es
that conveyed useful and nonobvious information. Admittedly some of the rem= ovals
were judgment calls; however, the point remains that easserts should not wa= ste
the reader's time unnecessarily.

I = agree, but I think anything that's not obvious deserves to be documente= d (preferably in the form of an assertion). Such documentation avoids the n= eed to search for other places in the codebase and figuring out which invar= iants are guaranteed from the implementation. INT_MIN < 0 is already gua= ranteed by the C standard (although even that is somewhat subtle, given the= possibility of different widths and representations of integers, padding b= its, etc.),
--001a114063d2f702a8055cb5a3b6--