Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118482 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98928 invoked from network); 25 Aug 2022 23:55:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Aug 2022 23:55:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8C635180384 for ; Thu, 25 Aug 2022 16:55:17 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.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 16:55:17 -0700 (PDT) Received: by mail-vs1-f52.google.com with SMTP id 67so211113vsv.2 for ; Thu, 25 Aug 2022 16:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=i/Z98BBL6mO7ZUbw16Bm85NdVShNZomVfQ1chykwCI8=; b=ofliO2WtCa0cTKa6t/GDaFZEEqdJYlMRI0FQnidCrdW7ue7x+XUrrUs4hn5FZ+Y1GX uj6oa3rWueKc8aHAQfk5a0NGMtcBjU7EvnvUtRpB0gwyFfbXUXR7zlmyVUmCQiUCCB9z 7fxoMtg3GEcUD/sZPXNQKoCVHcTLPbueSuT2kc+H35JOEsAqCGJn85kUB9eEeZlKDHVk Rgm4CsjbuT1/lkfpE2IYAk/OyPVzfR5DOEr3xklBeH42Tm4H3rUCrc4oOMTy6eoxp6YO aZUmGGHHE2RfDl1dX2NBtZc046YAEt9v6OqT3tMKBJjWVXfH7rSVId83UBhwQlo/pSql IjXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=i/Z98BBL6mO7ZUbw16Bm85NdVShNZomVfQ1chykwCI8=; b=RLSYLJoNdzYVpcmi7u64sDz0n7eP+L6wLJuW8iIcImamyK8wxl1fwa1Kymzv4+69cl p2q+PeFSFQfQ5MiX/l9dihP/YFYhMqIjz94r0j2jWlHafqFb1yH6cJ85WvZtlD0j68/J 4mjy9Nxzl5kxeJj5Ugc3zZhi2Z3CZuhP5DqwFe75ki8ypAg67W81fhRPqQT5VxCgapX1 h5RIigWmoPoxxxpMfEjg1XHDtMmwiYSjguvKKycpCBmt+P0HwYQAZzxPCpSqotmwR0DI KkbsvJiDVk6zgZQtUpUXWRZmxp6/mzJ4mBHEeFHiXp3Bfo1GetXQMy9bTJHf2evppUX3 52ew== X-Gm-Message-State: ACgBeo3rk3TnXsvt50y1Ot7wTFNUah+6c5186vj7YjnW120ydsuxHjP1 1IhXdL5A3Gqkb3K/JgJmEaAupHkvq5EQUM1Wvsk= X-Google-Smtp-Source: AA6agR4RsCFRd1hq/fJcit6xZgPlLh+EKy+r2Q9eyvw2PnuWDKbR0ciKFm9vNmOmKK/JeNQGjx9FR2cAvKIuuBRPLFM= X-Received: by 2002:a05:6102:37c:b0:390:8199:483e with SMTP id f28-20020a056102037c00b003908199483emr2595540vsa.13.1661471716509; Thu, 25 Aug 2022 16:55:16 -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: Fri, 26 Aug 2022 01:55:05 +0200 Message-ID: To: David Gebler Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC json_validate() - status: Under Discussion From: dev.juan.morales@gmail.com (juan carlos morales) > Having actually compiled the branch and tried it out, I have to say regar= dless of whether validating arbitrarily large blocks of JSON without being = interested in the contents is a common or more niche use case, the memory s= avings ARE highly impressive. I had thought that because the function was b= uilt 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, th= e saving appears to be around maybe 20-25% (and it's not a significant amou= nt of time using either json_decode or json_validate, even on an input of t= his size, about half a second on my machine for both). But the memory savin= g 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 maintainabl= e change. > > As I've said, my feelings are irrelevant to the extent I'm not a voter, b= ut I am in principle a +1 thumbs up for including this now. > > David, thanks very much for sharing your results and opinion. RFC: https://wiki.php.net/rfc/json_validate Implementation: https://github.com/php/php-src/pull/9399