Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118480 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93321 invoked from network); 25 Aug 2022 22:44:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Aug 2022 22:44:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A289C1804B5 for ; Thu, 25 Aug 2022 15:44:23 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 25 Aug 2022 15:44:23 -0700 (PDT) Received: by mail-ej1-f52.google.com with SMTP id sd33so20894115ejc.8 for ; Thu, 25 Aug 2022 15:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=pYQY/7Guvu+NPOsFdkn+fWQVKUk87BCZtr5aEYOYt60=; b=cqL+TpTDu6zeCykG2nJkc6+67236K/dBZnRHJ75lkbGa11i4iCUb5SOEnzkgAJebdv lz/btUJeoLOK2sFzy8X0BVCe/cy+SqGd9Uq2uEIa+Ihgr3joYzq+s+UPUS2/9Lv2YXeo jG3wteeuURUaPD3HDFnzMC5Rvsg7Hw00BWslHSy5do0ULbwkgBwHanCR/waH1nkAhiJC W+Cxjrzkq7uLbm99zlMCIuFg0eiHToGRihRBl0AzuWdiSRiCfBxY0qAKwEpYouikmBd9 hEI2rieVEJLSHb0c6h1R3wgoICejHqzGfbM3yXMYyOusaJi6+JWUpbgYSMBqzvv4NoI9 whNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=pYQY/7Guvu+NPOsFdkn+fWQVKUk87BCZtr5aEYOYt60=; b=29L3Cytp9xiH6II2ivTilk/eVbQkpwGmaCail5muqOAnR7D7JVSk4EJ6jwe9vmI20S gnUJSjp78yOx8S/haBIu7J4USTQ2iEn2tGn1d++1qiGpvp06M7viBe/IzZTty4PkbkFH DKOh7o5NbbrPrubvj9+zEGKqlIjSka69J6ruRCxCS0IKVxIRBrACINifcZaRCRdi06Sg RqUvfZQhnjmczNmHmVXk80S+WNOgXYb7D+hm2TnomzHWjssOtsqIWPDsUOjn5jaDrcLu pI/BrohdTEF9726l3XflnvkoZCqu2PXK9/HcAmsvuuMyGj2AHxQd8wkD9rNrI3JP/FsT IymQ== X-Gm-Message-State: ACgBeo1S+yuur7bJm1kvN7WwmJHyHlaV4+LLERGVZ6pVIjDe2gbw2QJT G965rUnP8xDNoal+soCTPE/J0KdwkMMRJ2K2vNw= X-Google-Smtp-Source: AA6agR5BoXSTgcKiQ5gjo1Dk6uj1aFa+TmsyYpN64jT/oJ67w7aljkNQ4W18j9r8vKt1+3/7IBX2y4K1CPBHCUT0z3I= X-Received: by 2002:a17:907:1611:b0:73d:6d23:5787 with SMTP id hb17-20020a170907161100b0073d6d235787mr3750154ejc.231.1661467461681; Thu, 25 Aug 2022 15:44:21 -0700 (PDT) MIME-Version: 1.0 References: <30876360-1d4f-8097-0b58-fd902f1fa009@gmail.com> <816aeb23-523a-f81a-7eba-d12a4d7292d3@gmail.com> In-Reply-To: Date: Thu, 25 Aug 2022 23:44:10 +0100 Message-ID: To: juan carlos morales Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000dc060e05e7188908" Subject: Re: [PHP-DEV] RFC json_validate() - status: Under Discussion From: davidgebler@gmail.com (David Gebler) --000000000000dc060e05e7188908 Content-Type: text/plain; charset="UTF-8" Having actually compiled the branch and tried it out, I have to say regardless of whether validating arbitrarily large blocks of JSON without being interested in the contents is a common or more niche use case, the memory savings ARE highly impressive. I had thought that because the function was built on top of the existing parser and is still parsing the entire string (or up until invalid JSON is encountered), the performance saving for a very large input would be smaller than it is. I tested using a 75MB valid JSON input - a string large enough that it's not going to be very common. The processing time isn't hugely different, the saving appears to be around maybe 20-25% (and it's not a significant amount of time using either json_decode or json_validate, even on an input of this size, about half a second on my machine for both). But the memory saving is enormous, almost total. Gone from needing ~5x the size of the input to almost literally just a few extra bytes. I'm persuaded now on both that benchmarking and having had a closer look at the implementation PR, which is clearly a minimal and easily maintainable change. As I've said, my feelings are irrelevant to the extent I'm not a voter, but I am in principle a +1 thumbs up for including this now. --000000000000dc060e05e7188908--