Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112846 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1340 invoked from network); 12 Jan 2021 01:03:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Jan 2021 01:03:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 807ED1804A7 for ; Mon, 11 Jan 2021 16:40:49 -0800 (PST) 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 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 11 Jan 2021 16:40:48 -0800 (PST) Received: by mail-ej1-f47.google.com with SMTP id n26so1021716eju.6 for ; Mon, 11 Jan 2021 16:40:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Ajvo/h09ksQiyMKJhHpyGT74AH8wh7lXwEf4f/Fn6U4=; b=mYnOYoAqhek/o5zz5TKMVCNrOZyoqjSGhoAOFqQZnkXZDMh6aVzPH3x0U8mgZdZoGI 3V9ZbZMxipgefvaeW8B7CavLBDsUn1ggtKwV+5qfN6mtdELk+acdxQh8Kqo2pyNY9Kyg IAwZn+22sMhe/RnVQbLfmTe4A6lqvSL+cR5QqLFcRjSRp/b1UM2n7emPNcIhg6DZisBi FrN0Hvvf49BqhWcCmm7bAxly6/sCq7pkh6dlzlnU1MEPBGo63Yp5UQZzOAw6qP/gSRDG VXYgFmLXiTfh/QEaJwU8B2CCBBPRssdYLUWrjtKG5tXr6haedGsOOswqZMU0cyKTHtdw YUFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Ajvo/h09ksQiyMKJhHpyGT74AH8wh7lXwEf4f/Fn6U4=; b=ee0x46RrPJ/BNAEKB4iXUL3e5oOxi1ojQREcuQ/EriqWT+0egvoZ+XkCgtPzG67WvR 1Tv3n04jkYRgrmd7KyEAGCA3zBhNsVRyi4yfMAkKbN/GW96U9fOjXyMzhRTx/y1wu0mD i3Fn9CbrhJgfv6lhJYDYGIU9D3LMrIVEHjpUOzHYC4uxuYXq3BjJ7Ta3r2tnLO9srnfe zQmhf0GMSdNAw0FW1zs2emNTWHBjpJEVHU9oiaFe24t2LvIiK9eoIHjAP6j5nvfklzJe uCWfhhvtEzCixaUwgO8wu6gp2uBHmdWtvrQ2ohciMEkK5KW3R/WQ9U7+mDyS2UnOu52G Wspg== X-Gm-Message-State: AOAM531jOSwyvFDIC5tllwifPjdBri27cwIif3i/uVuHn4qiAJE/M7ks Kpoyj33UDnP1ppePTX08V2vYRjZ6NU5h4JnSk9h9UXkivTMDVg== X-Google-Smtp-Source: ABdhPJxiDPBF6SKfow3X8tLyLlk6WtlZEmqSpBLvH4pRBRW3xgGHH7UMsBSjyiczaQ/DJwPQS0GYmTURNbzbaFiqco0= X-Received: by 2002:a17:906:2681:: with SMTP id t1mr1341994ejc.29.1610412047145; Mon, 11 Jan 2021 16:40:47 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 12 Jan 2021 09:40:36 +0900 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000003203605b8a94637" Subject: Re: [RFC] Object-scope RNG implementation From: zeriyoshi@gmail.com (Go Kudo) --00000000000003203605b8a94637 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I have made some fixes to the implementation based on review. The current implementation can be found at the following address (Thanks Tyson: https://github.com/zeriyoshi/php-src/commit/5ff8882a8fbfaf4ffd5cc42fb5853c4= a1a00c182 ) https://github.com/php/php-src/compare/master...zeriyoshi:object_scope_rng_= type2 The points that seem to need discussion at the moment are as follows: - Do we need this feature? First of all this is more important than anything else. I think it is necessary from a testing perspective and because it is going to be difficult to consider global state in the future and some functions are using RNGs at times that the user is not aware of. - Do we need support for userland implementations? I think this is necessary. Fixing the output of an RNG to an arbitrary result is useful for testing special patterns. However, this is currently problematic. At the moment, there is a complete distinction between C implementations and userland implementations. This is done based on whether the class is user-defined or not. The classes provided by the C implementation are always final and cannot be extended by the user. I would like to make it extensible if possible, but currently I don't know how to make it compatible with speed. - How do you deal with the mixed 64/32 bit issue? Some PRNGs, including XorShift128+, keep their internal state in uint64. The XorShift128+ implementation supports serialization, which preserves the internal state in a 32bit environment by converting numbers to strings. However, __construct() still accepts seed values in int. This means that certain states cannot be reproduced in a 32bit environment. I think the support for 32bit environment will be reduced, and the serialization support was done to help with the migration. Should __construct() still accept a seed value in a string, so that all states are available in a 32bit environment? - What should we do with next64()? The next64() method of the C implementation of RNG always throws a ValueError in 32bit environments for now. However, in a user implementation, everything is left up to the implementation. Personally, I think it would be better to define another interface for the next64() method that inherits from RNGInterface, what do you think? Regards, Go Kudo 2021=E5=B9=B41=E6=9C=889=E6=97=A5(=E5=9C=9F) 19:00 Go Kudo : > Hi internals. > > I think I'm ready to discuss this RFC. > https://wiki.php.net/rfc/object_scope_prng > > Previous internals thread: https://externals.io/message/112525 > > Now is the time to let me know what you think. > > Regards, > Go Kudo > --00000000000003203605b8a94637--