Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118018 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 23373 invoked from network); 20 Jun 2022 13:51:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Jun 2022 13:51:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CF519180539 for ; Mon, 20 Jun 2022 08:40:08 -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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 20 Jun 2022 08:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1655739607; bh=PpN/XoAIybRfc99AZz73w0UINkHB60G/kxLNyx3x6fI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=HqMYmcV7Yd/ViiYKMKXK1Yju1CeKgdK5Hy97rzHPHJkkCqnApctv1gvXHRnXKRvR8 VCa/SKVE8XZ33adTSvz8+5MaJ2yoxN96h2WZBvm+3uzx0wbPvFIacLM136fxjJ5hC+ /Ka+L03Vg0eSvsFYu8FVJiZKR5RmqTFEnPBwmVnqA5lJQeX5xwWVV8UwOrS+2M2ahB 6JkQmS0VbkAD/nZ3oiNXAGRxGTQ0I3v8CoEvbqsAwAmE86S5vtWbUPuYjHkrZcgUai WO8PrJAQqE1MAG5LpsfzSG+K6C5Bs/3Iv1LqWkUFyxuAznpNyjmBZmuYjlnHkgX/rr WDB9uRrtfKBAg== Message-ID: <64f0b7c5-6b51-2607-53cb-c292ab3a6dc7@bastelstu.be> Date: Mon, 20 Jun 2022 17:40:06 +0200 MIME-Version: 1.0 Content-Language: en-US To: Nicolas Grekas , Go Kudo Cc: PHP Internals List References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] [Under Discussion] Random Extension Improvement From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi On 6/20/22 16:57, Nicolas Grekas wrote: > I'm wondering: does Random\SerializableEngine extend Random\Engine? Can > this be mentioned in the RFC? If not, what about making it this way? Having > this interface only contain __(un)serialize would look strange to me, aka > too broad for the name and the purpose. Yes, it does. All the other interfaces extend Random\Engine as well. See the stub at: https://github.com/colopl/php-src/blob/upstream_rfc/scoped_rng_for_pr/ext/random/random.stub.php > I'm also wondering: is CombinedLCG worth it? I must admit I don't know when > I should use it instead of MT19937. If the RFC passes you really should use neither: - CombinedLCG: That's a horrible RNG, that is implemented for backwards compatibility with the existing functionality. - MT19937: That one is not quite as horrible, but it comes with 2.5kB of state. It's also implemented for backwards compatibility with the existing RNGs (it's what backs rand() and mt_rand()). Use 'Secure', you can't do anything wrong with that and that's why it's the default for the Randomizer. If you need performance or if you need support for seeding then either use PCGOneseq128XslRr64 or Xoshiro256StarStar (depending on whether the latter makes it into the extension). > Since the names are all super opaque to many of us, documentation should be > very clear about the use case of each implementation... (if can reduce the > number of implementations, that's even better :) ) Regarding the names: Yes, they are opaque, but will become a little less opaque if the extension RFC passes, because then the names will refer to a very specific implementation of standard RNGs, making them Googleable. For Xoshiro256StarStar the upstream documentation is here: https://prng.di.unimi.it/ For PCGOneseq128XslRr64 the upstream documentation is here: https://www.pcg-random.org/ But I agree that the documentation should help the user make an educated choice. Best regards Tim Düsterhus