Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118318 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94479 invoked from network); 30 Jul 2022 04:38:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Jul 2022 04:38:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DBC5B180380 for ; Fri, 29 Jul 2022 23:37:20 -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-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) (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 ; Fri, 29 Jul 2022 23:37:20 -0700 (PDT) Received: by mail-yb1-f179.google.com with SMTP id 204so10249787yba.1 for ; Fri, 29 Jul 2022 23:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EdlLZj3hrjEygOzEYJHFW7pFZYIjVCPNmkCNvZtKNas=; b=G7X2zabA/wda/yCtTG7qsj4c63El0sF8+Ybyhl841WkBqKBugba0tBUNI43oOQloC0 MOWbLS4M9pVYk+1PLAQk9mYpVk7DqhHxlyo/bl41sbVZDPCkygelGvZos+bUpsEb+23n WuE353ldgpiT1ZgBnPA/dGy/Z8P+bJHY+6m653uSaPgyhy4KYfLZ35mSQqBub5AC6fql LceQsSrw8PenYBWnIdXdUzhKMeKetwXmyYb6kePzIyTtoCB7me7WOYnsokOHfXS1pDTp f5S7NIfuIDorxjJAnCVq0hKM/NFYL+/lNDCQdh5pk70kUcTd1xUgsDYfESpUIprQdu0a tnfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EdlLZj3hrjEygOzEYJHFW7pFZYIjVCPNmkCNvZtKNas=; b=mYQwW//+r+l/8iHdxYJ4QsjU8tdm+bPeXWfFEelGvhql8GHZzVaLK9CeJfv0BqSNjL LX55MuwvXvZRa6ig/fvsRJJqGYXLP7fR1Pm+muZwQeARR//gxI5Y8whpM+8embMUz+Mo 1t/GwSvYVyoTaCqvnLO6YkU4k17cBulJL0eRKkVABhBwHTEtGacjcndFpaH1+5v15bN5 /z6TCMG8WGuJ/z2pD9Gz73Ov8qH+CoAbJ8+hFM1Ce/LFqdaLTxcx3/6RuwW5YJEQ6Gym yQYvKw8mkiiE+6Y5bDldwEQNS3GlG3MIapKJ/TIr0Ytf8VeZhOISNz1hmdlHA0skuDB9 NDtQ== X-Gm-Message-State: ACgBeo0hWGXGOJXZECYIKfO8gHqYZIZclawIC4FEO8YyRfsCylTMpzKd A03twgsOCe8U6jiL4zrwMbSeLjNxLBt6fPDX2TFq/rQM3E8akgiD X-Google-Smtp-Source: AA6agR7yNpn32GW3MD9TI5QOHV1wPYLNTOXShDyaeVZqdiqiq4/oPHg2gSfG7wyvbgjW0kZn6HmfQHhdvlRqJU7q/64= X-Received: by 2002:a25:6f02:0:b0:66f:5acc:7866 with SMTP id k2-20020a256f02000000b0066f5acc7866mr5142996ybc.461.1659163039894; Fri, 29 Jul 2022 23:37:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 30 Jul 2022 08:37:09 +0200 Message-ID: To: Jordan LeDoux Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000009e11ab05e4ffff99" Subject: Re: [PHP-DEV] RFC Idea - is_json - looking for feedback From: dev.juan.morales@gmail.com (juan carlos morales) --0000000000009e11ab05e4ffff99 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Just want to clarify that when I mentioned the use of memory, I wrote down the function "memory_get_usage()", which basically gives us the memory handle by php that is related to the memory_limit INI setting. Now I will provide a benchmark I have done really quick: # Code used (I have the implementation of is_json() done already) ) escribi=C3=B3: > > > On Fri, Jul 29, 2022 at 7:27 AM juan carlos morales < > dev.juan.morales@gmail.com> wrote: > >> # Why this function ? >> >> At the moment the only way to determine if a JSON-string is valid we hav= e >> to execute the json_decode() function. >> >> The drawback about this, is that json_decode() generates an in memory an >> object/array (depending on parameters) while parsing the string; this >> leads >> to a memory usage that is not needed (because we use memory for creating >> the object/array) and also can cause an error for reaching the >> memory-limit >> of the php process. >> >> Sometimes we just need to know is the string is a valid json or not, and >> nothing else. >> > > You say that you have a first-pass at the implementation done. I'd be > curious to see it. My initial thought was that in order to validate the > string, you likely need to allocate extra memory as part of the validatio= n > that depends on the string size. You'd definitely save the overhead of a > ZVAL, but for such an object that overhead is likely negligible. > > So I guess my question would be: in the actual implementation that lands, > how much memory would this actually save compared to json_decode()? This > seems like it would make the RFC tricky, as the purported benefit of the > RFC depends very tightly on the implementation that lands. > > Jordan > --0000000000009e11ab05e4ffff99--