Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118335 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 48370 invoked from network); 1 Aug 2022 03:20:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Aug 2022 03:20:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8542D180384 for ; Sun, 31 Jul 2022 22:19:30 -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,HTML_MESSAGE, 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 ; Sun, 31 Jul 2022 22:19:30 -0700 (PDT) Received: by mail-vs1-f52.google.com with SMTP id c3so10134230vsc.6 for ; Sun, 31 Jul 2022 22:19:30 -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=Dw/zDCMKktKPgl7N3gz2EiiaG0R4i/16Qd+VYTUjmKs=; b=CwbAcpCkI0Mx5rwymfW1ZG75U1JxfrK7Q8TctgBwTj17H7cfCcXbUPrSvUpQf0zE6h 0NYlj0SOvxxEWwecLartC+XxcbN74M4RUo/53cCo2KlQHqYhWnC6Vy9QgAEflzzzC1KZ XOlpdWmIaTba7Qo49aHF0h9MFbOaNp3NAx+oWyYshxAsfs0o3AEpMzuJ6K4WIh/KT94y /Lu9W6VWd7554kUBM1nCIM2SQ8peDz3HLTNfehnlPDmr5ngAlPnIHFJzeEZKXkUfczJf 4U5hFlmnWL88GaeGna0jsCT2eN2Wywz0Y9OC3UwXo5IeH3rcplfLyfOdHUqs8QVEg7v4 kypA== 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=Dw/zDCMKktKPgl7N3gz2EiiaG0R4i/16Qd+VYTUjmKs=; b=LFITWd9L1ye+Z7PUtd5fjtHHlj4OCNSXCajf+u/IKAsPsc5uZaQLqDCRXHfTw0odzW IzCzcjuet+HL7ZV7F5QYwna1PhkXqLojxGuXXd2ZyvW/7zHMxuQ+87pjwAYBHPmJXmBJ E57MKz25ukuQ27dt7WpGjMY/TNIcR1fWtlevCXCtAJZjgqpIsiEq6FV4p5uATcyVayB6 cDZvCmPHQRu8OuBZx2jxJIZ+A6SQnM88zZoIGHJP7x3RGxuoP9MjB/XOHizngYISvYCQ rHpFGA6wnv7mUTyxEdBTedIhRdjE75Olun2YJpc8PLeWJB8M6ZZR47zbjln5Q6c6nQ1Y Mi7A== X-Gm-Message-State: ACgBeo1MWUJ8M4D/O6yGr1ZAp8LrBCE/WnqI+g60hdA6YP6EFLi9g86a 4+kESh7Y1ZmVmpSbYM5HRZB32vDcWTkEWfPVNw0= X-Google-Smtp-Source: AA6agR7HFZWj7knMLh1nIOJuc+QgbiqxFN1X7/qy5MIM1CDcr3ennk+H874MxSf85RJuxzU0aOnWC+TwVG/qBucEi64= X-Received: by 2002:a05:6102:441c:b0:378:fcdd:d951 with SMTP id df28-20020a056102441c00b00378fcddd951mr2759814vsb.22.1659331169400; Sun, 31 Jul 2022 22:19:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 31 Jul 2022 22:19:17 -0700 Message-ID: To: juan carlos morales Cc: Larry Garfield , php internals , Nikita Popov Content-Type: multipart/alternative; boundary="000000000000eabdea05e527240d" Subject: Re: [PHP-DEV] RFC Idea - is_json - looking for feedback From: jordan.ledoux@gmail.com (Jordan LeDoux) --000000000000eabdea05e527240d Content-Type: text/plain; charset="UTF-8" On Sun, Jul 31, 2022 at 11:23 AM juan carlos morales < dev.juan.morales@gmail.com> wrote: > ----- Benchmark including memory_get_peak_usage ----- > > # json_decode() > > Megas used before call: 79.23828125 > PEAK Megas used before call: 128.00390625 //<---- > Megas used after call: 3269.23828125 > PEAK Megas used after call: 3309.23828125 //<---- > Difference: 3190 > PEAK Difference: 3181.234375 //<----- > Time: 12.109144926071 seconds > > # is_json() > > Megas used before call: 79.23828125 > PEAK Megas used before call: 128.00390625 //<---- > Megas used after call: 79.23828125 > PEAK Megas used after call: 128.00390625 //<---- > Difference: 0 > PEAK Difference: 0 //<----- > Time: 5.4504480361938 seconds > This is actually suggesting a compelling case to me if this held up under close inspection of the code. You've certainly shown that it solves a problem that userspace is sort of half-solving, due to the limitations of the language around memory. > I want to clarify, as I previously mentioned, I did not develop any parser > at all, the parser already exists in PHP and is use by json_decode(), in > short words , what I propose is to create a new function, as an interface > to THE EXISTING PARSER, only, and only, to check if a string is a valid > json-string or not. > This is curious... the existing parser *should* need to allocate the memory. This makes me wonder if the above performance would hold up under scrutiny, *but* you have fully convinced me at the point (not that I have a vote) that it's worth the RFC to explore it. > Regarding publishing the a PR with my implementation, is out of context at > the moment, because we are discussing if a functionality like this should > be included or not, and nothing else. Also I am pretty sure that if this > gets a YES from the community (so far seems so), and I show my > implementation, someone will tell me that it could be done in a different > way , and is totally fine, is great actually. But now, at this moment, > everything is about the functionality. > Ah, okay. That I understand, even if I find it a tad frustrating. You want to understand if people are on-board with the merits of the idea without it being attached to your particular proof-of-concept code. If I'm reading the feedback correctly though, I think that any votes the RFC received would be heavily dependent on the eventual implementation and its performance though. So I think the RFC will be pretty closely tied to an implementation regardless of your efforts. Jordan --000000000000eabdea05e527240d--